Nested rails are formed using a simple form?

How can I get the form of nested rails? I am having trouble setting this up properly. Right now I have:

<%= simple_form_for @user do |f| %>

  <%= f.input :city %>
  <%= f.input :address %>
  <%= f.input :zipcode %>
  <%= f.association :interests, :as => :check_boxes, :label => false %>
  <%= f.association :holidays, :as => :check_boxes, :label => false %>

  <%= f.simple_fields_for :friend_birthdays do |friend_birthday| %>
    <%= f.input :name %>
    <%= f.input :gender, :collection => ['male','female'] %>
  <% end %>
  <%= f.button :submit %>
<% end %>

f.associationworks great for my models of interests and holidays, as they only need to collect one attribute. However, the model friend_birthdayshas the same exact relationship as (interests and holidays) with the user model, but requires editing / adding several attributes. Any ideas?

+3
source share
1 answer

Rails 3+, - . accepts_nested_attributes_for fields_for . .

simple_form, , Rails. , , :

<%= f.simple_fields_for :friend_birthdays do |friend_birthday| %>
  <%= friend_birthday.input :name %>
  <%= friend_birthday.input :gender, :collection => ['male','female'] %>
<% end %>

, , .

+4

All Articles