The reason you can't use the same method as the other question in your post is bc @book is not a nested attribute of user. You are only creating a form for one new book, so without anything special in the controller, rails will only save one book. One option is to make books a nested attribute of user so that you can create multiple books at once. Here is how you need to set up your models and form to handle nested attributes.
Class User < ActiveRecord::Base
has_many :books
accepts_nested_attributes_for :books, :reject_if => lambda { |b| b[:title].blank? }
attr_accessible :books_attributes
end
Class Book < ActiveRecord::Base
belongs_to :user
end
The reject_if will ignore any records that are submitted to the controller without a title. You will want this since you are assuming that many users won't use all 10 fields. Below is your form.
<%= form_for @user do |f| %>
<%= f.fields_for :books, [Book.new]*10 do |book| %>
<%= book.text_field :title %>
<%= book.association :book_category %>
<% end %>
<%= f.submit %>
<% end %>
It is important to note that this form will be submitted to the Users controller since it is a user form. The users controller will handle creating/updating all the books like it would any other attribute of user since books are now accepted as a nested attribute. For more examples checkout this Railscast on nested attributes.
As I mentioned above, this is only one option. If you do not want to make book a nested attribute of user then another option is to generate your 10 sets of book input fields like you are already doing and then break apart the params hash in the create action in the Books controller. By doing this you could loop through the hash and create a book for each set of inputs. This is much more "hacky" than using accepts_nested_attributes_for but it is another option so I figured I would mention it.