【发布时间】:2012-12-24 05:31:21
【问题描述】:
快速轨道部分,假设我有两个模型用户和角色,我想根据某个角色创建用户的索引/列表,我该如何在我的控制器中构建它
是不是有点像
#first create the association
@user = role.build
#then build the index based on a Role of role_id = 2
@userrole = @user.where(@user.role_id == 2)
我知道这是伪代码,但这是正确的吗?什么是正确的 rails 代码?
【问题讨论】:
标签: ruby-on-rails-3 model-view-controller controller