【发布时间】:2014-03-17 10:47:18
【问题描述】:
我想要用户注册表单中的下拉菜单,该下拉菜单将设置属于某个部门的用户角色。这是模型
class Department < ActiveRecord::Base
has_many :roles
end
class Role < ActiveRecord::Base
belongs_to :department
has_many :users
end
class User < ActiveRecord::Base
belongs_to :roles
end
在注册表中我正在尝试这个:
=form.grouped_collection_select(:user, :role_id, @departments, :roles, :title, :id,:title)
这会产生错误 :title:Symbol 的未定义方法 `merge'
Department 和 Role 两个模型都包含“title”
我不知道我缺哪里了
【问题讨论】:
-
只是尝试没有价值
=form.grouped_collection_select :user, :role_id, @departments, :roles, :title, :id, :title -
@SaidKaldybaev 哦,我只是尝试了没有价值。查看编辑
-
使用值它给未定义的方法用户并且没有值提到的错误
标签: ruby-on-rails ruby-on-rails-4 haml grouped-collection-select