English 中文(简体)
mongoid, embedy_many, brief_form
原标题:mongoid, embedy_many, simple_form
问题回答

你们也许希望尝试这样的事情:

= simple_form_for @team do |form|
  = f.input :name
  = f.simple_fields_for @team.players do |player_form|
    = player_form.input :name

Just keep in mind that you will have to create a new player in the team before the form will show up. In your controller(controller):

def new
  @team = Team.new
  8.times { @team.players.new } #for 8 players
end




相关问题
How to skip callbacks on Mongoid Documents?

My question is similar to this one How to skip ActiveRecord callbacks? but instead of AR I m using Mongoid, It seems like that isn t implemented yet in the current version of Mongoid, so I d like to ...

mongoid, set_table_name & attr_accessible

I m using rails3 edge and mongoid 2beta6 with ruby 1.9.2-head. How can I manually change the table name, just like set_table_name for ActiveRecord? For example my model Signup should use the table "...

How to store UTC time values in Mongo with Mongoid?

The behavior I m observing with the Mongoid adapter is that it ll save time fields with the current system timezone into the database. Note that it s the system time and not Rail s environment s ...

How can i generate mongoid.yml config in Rail 2.3.5?

As the title says, how can i generate the default mongoid.yml config file on Rail 2.3.5? I try to use the ´rails generate mongoid:config´ command but it just generates a new app. And also, I would ...

Mongoid or MongoMapper? [closed]

I have tried MongoMapper and it is feature complete (offering almost all AR functionality) but i was not very happy with the performance when using large datasets. Has anyone compared with Mongoid? ...

热门标签