Im making nested attributes for profile on the user model and I also need to validate the profile info so I put User model has_one :profile accepts_nested_attributes_for :profile validates_associated :profile <--- To validate values attr_accessible :profile <----to allow mass assingment Profile model belongs_to :user, :dependent => :destroy >>> Some Validations <<< But Im getting Profile(#30752520) expected, got ActiveSupport::HashWithIndifferentAccess(#26724528) Becouse of the attr_accessible :profile I think, but if I dont have that line I cant enter values for profile, Anyways. when I take that line off, my profile forms isn''t validated, this problem come when changing to rails 3.0.7 -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Tomas, Try changing your mass-assignment protection line to: attr_accessible :profile_attributes If that still doesn''t work send your view code. If you haven''t already ready read the nested attribute docs, they explain things pretty well: http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html Matt Daubert On May 14, 10:35 pm, "Tomas R." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Im making nested attributes for profile on the user model and I also > need to validate the profile info > so I put > > User model > > has_one :profile > accepts_nested_attributes_for :profile > validates_associated :profile <--- To validate values > attr_accessible :profile <----to allow mass assingment > > Profile model > > belongs_to :user, :dependent => :destroy > >>> Some Validations <<< > > But Im getting > > Profile(#30752520) expected, got > ActiveSupport::HashWithIndifferentAccess(#26724528) > > Becouse of the > attr_accessible :profile > I think, but if I dont have that line I cant enter values for profile, > Anyways. when I take that line off, my profile forms isn''t validated, > this problem come when changing to rails 3.0.7 > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I added that line but still dont work User Form <%= form_for @user do |f| %> <%= render ''shared/error_messages'', :record => @user %>>>> Some Field Tags <<<<p> <%= f.fields_for @user.build_profile do |builder| %> <%= render ''profile_form'', :f => builder %> <% end %> </p> <p><%= f.submit (@user.new_record? ? "Registrarse" : "Editar") %></p> <% end %> Profile Fields <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> <p> <%= f.label :surname %><br /> <%= f.text_field :surname %> </p> -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fixed: Changed @user.build_profile from view to controller -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.