我需要group_id
使用下面列出的 Rails collection_select 代码保存在我的用户文档中
模型用户:
class User
include Mongoid::Document
include Mongoid::Timestamps
include Amistad::FriendModel
field :name, :type => String
field :email, :type => String, :default => ""
field :encrypted_password, :type => String, :default => ""
#relations
belongs_to :school
belongs_to :group
模型组
class Group
include Mongoid::Document
attr_accessible :name, :degree
field :name, type: String
field :degree, type: String
has_many :users
并生成表格:
<%= form_for(@user) do |f| %>
<%= f.email_field :email %></div>
<%= f.password_field :password %>
<%= f.collection_select :group_id, Group.all, :id, :name %>
<%= f.submit "Sign up" %>
<%end%>
这将保存用户文档,而不是在 collection_select 中保存 group_id 提及,任何想法