i m 寻找一种方式管理多种嵌入物体。
找到了由高温师培养的解决方案。
但是,如果是简单的,我会这样做。 形式
形式:
= semantic_form_for @team do |form|
= @team.players.each do |player|
= form.inputs :for => [:players, player] do |player_form|
= player_form.input :name
最好
样本
class Team
include Mongoid::Document
field :name, :type => String
embeds_many :players
end
class Player
include Mongoid::Document
embedded_in :team, :inverse_of => :players
field :name, :type => String
field :active, :type=> Boolean # checkboxes
end