[Rails] Nested Attributes in Rails 3
Hello All,
I am stuck in nested attributes:-
here is my code :-
User.rb :-
has_one :address
accepts_nested_attributes_for :address
Address.rb :-
belongs_to :user
_form.html.erb:-
<%= simple_form_for @user ,:validate => true do |f| %>
<%= f.fields_for :address do |d| %>
<%= d.input :first_name %>
<%= d.input :last_name %>
<% end %>
<%= f.input :email %>
<% end %>
in user_controller.rb:-
In new as well as create method I tried with:-
@user = User.new
@user.build_profile
But still I am getting the error as :-
Can't mass-assign protected attributes: address_attributes
Any Suggestions ??
Thanks....
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/dd447A7hSYwJ.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home