I try to update a nested model (version) and get this error. any tips would be great! my models: location has_many :versions # view <% form_for location do |location_form| %> <ul class="location"> <li><%= location_form.label location.section %></li> <li><%= location_form.label location.sub_section %></li> <li><%= location_form.label location.place_holder %></li> </ul> <div class="content-area"> <% location.versions.each do |version| %> <div class="content" > <% location_form.fields_for version do |version_form| %> <%= version_form.label version.environment %> <%= version_form.text_area :content %> <% end %> </div> <% end %> <%= submit_tag %> </div> <% end %> #controller def update @location = Location.find(params[:id]) @location.update_attributes(params[:location]) #error: unknown attribute: version redirect_to( locations_path ) end # the params {"location"=>{"version"=>{"content"=>"hello human. glass robot want you to join Glass"}}, "commit"=>"Save changes", "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", "id"=>"2"} -- 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.
Where''s the error message? On Tue, Apr 6, 2010 at 8:49 PM, oren <orengolan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I try to update a nested model (version) and get this error. any tips > would be great! > > my models: location has_many :versions > > # view > > <% form_for location do |location_form| %> > <ul class="location"> > <li><%= location_form.label location.section %></li> > <li><%= location_form.label location.sub_section %></li> > <li><%= location_form.label location.place_holder %></li> > </ul> > > <div class="content-area"> > <% location.versions.each do |version| %> > <div class="content" > > <% location_form.fields_for version do |version_form| %> > <%= version_form.label version.environment %> > <%= version_form.text_area :content %> > <% end %> > </div> > <% end %> > <%= submit_tag %> > </div> > > <% end %> > > #controller > > def update > @location = Location.find(params[:id]) > -0tkTgdqk2elcQ7ALCyhmPw@public.gmane.org_attributes(params[:location]) #error: unknown > attribute: version > redirect_to( locations_path ) > end > > # the params > > {"location"=>{"version"=>{"content"=>"hello human. glass robot want > you to join Glass"}}, "commit"=>"Save changes", > "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", > "id"=>"2"} > > -- > 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. > >-- 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.
ActiveRecord::UnknownAttributeError in LocationsController#update unknown attribute: version RAILS_ROOT: /home/oren/misc/projects/borderstylo/content /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2746:in `attributes='' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `each'' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2742:in `attributes='' /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ active_record/base.rb:2628:in `update_attributes'' /home/oren/misc/projects/borderstylo/content/app/controllers/ locations_controller.rb:29:in `update'' On Apr 7, 3:31 am, Ryan Waldron <r...-L2nCScK6t0HQT0dZR+AlfA@public.gmane.org> wrote:> Where''s the error message? > > On Tue, Apr 6, 2010 at 8:49 PM, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I try to update a nested model (version) and get this error. any tips > > would be great! > > > my models: location has_many :versions > > > # view > > > <% form_for location do |location_form| %> > > <ul class="location"> > > <li><%= location_form.label location.section %></li> > > <li><%= location_form.label location.sub_section %></li> > > <li><%= location_form.label location.place_holder %></li> > > </ul> > > > <div class="content-area"> > > <% location.versions.each do |version| %> > > <div class="content" > > > <% location_form.fields_for version do |version_form| %> > > <%= version_form.label version.environment %> > > <%= version_form.text_area :content %> > > <% end %> > > </div> > > <% end %> > > <%= submit_tag %> > > </div> > > > <% end %> > > > #controller > > > def update > > @location = Location.find(params[:id]) > > -0tkTgdqk2elcQ7ALCyhmPw@public.gmane.org_attributes(params[:location]) #error: unknown > > attribute: version > > redirect_to( locations_path ) > > end > > > # the params > > > {"location"=>{"version"=>{"content"=>"hello human. glass robot want > > you to join Glass"}}, "commit"=>"Save changes", > > "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", > > "id"=>"2"} > > > -- > > 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 athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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.
Hi Oren, Try this "accepts_nested_attributes_for :versions" in the location.rb file. Cheers! On Apr 7, 1:30 am, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ActiveRecord::UnknownAttributeError in LocationsController#update > > unknown attribute: version > > RAILS_ROOT: /home/oren/misc/projects/borderstylo/content > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > active_record/base.rb:2746:in `attributes='' > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > active_record/base.rb:2742:in `each'' > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > active_record/base.rb:2742:in `attributes='' > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > active_record/base.rb:2628:in `update_attributes'' > /home/oren/misc/projects/borderstylo/content/app/controllers/ > locations_controller.rb:29:in `update'' > > On Apr 7, 3:31 am, Ryan Waldron <r...-L2nCScK6t0HQT0dZR+AlfA@public.gmane.org> wrote: > > > > > Where''s the error message? > > > On Tue, Apr 6, 2010 at 8:49 PM, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I try to update a nested model (version) and get this error. any tips > > > would be great! > > > > my models: location has_many :versions > > > > # view > > > > <% form_for location do |location_form| %> > > > <ul class="location"> > > > <li><%= location_form.label location.section %></li> > > > <li><%= location_form.label location.sub_section %></li> > > > <li><%= location_form.label location.place_holder %></li> > > > </ul> > > > > <div class="content-area"> > > > <% location.versions.each do |version| %> > > > <div class="content" > > > > <% location_form.fields_for version do |version_form| %> > > > <%= version_form.label version.environment %> > > > <%= version_form.text_area :content %> > > > <% end %> > > > </div> > > > <% end %> > > > <%= submit_tag %> > > > </div> > > > > <% end %> > > > > #controller > > > > def update > > > @location = Location.find(params[:id]) > > > -0tkTgdqk2elcQ7ALCyhmPw@public.gmane.org_attributes(params[:location]) #error: unknown > > > attribute: version > > > redirect_to( locations_path ) > > > end > > > > # the params > > > > {"location"=>{"version"=>{"content"=>"hello human. glass robot want > > > you to join Glass"}}, "commit"=>"Save changes", > > > "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", > > > "id"=>"2"} > > > > -- > > > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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 already have this: has_many :versions, :dependent => :destroy accepts_nested_attributes_for :versions On Apr 7, 11:15 am, Nicolas Iensen <nicolas.ien...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Oren, > > Try this "accepts_nested_attributes_for :versions" in the location.rb > file. > > Cheers! > > On Apr 7, 1:30 am, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > ActiveRecord::UnknownAttributeError in LocationsController#update > > > unknown attribute: version > > > RAILS_ROOT: /home/oren/misc/projects/borderstylo/content > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > active_record/base.rb:2746:in `attributes='' > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > active_record/base.rb:2742:in `each'' > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > active_record/base.rb:2742:in `attributes='' > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > active_record/base.rb:2628:in `update_attributes'' > > /home/oren/misc/projects/borderstylo/content/app/controllers/ > > locations_controller.rb:29:in `update'' > > > On Apr 7, 3:31 am, Ryan Waldron <r...-L2nCScK6t0HQT0dZR+AlfA@public.gmane.org> wrote: > > > > Where''s the error message? > > > > On Tue, Apr 6, 2010 at 8:49 PM, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I try to update a nested model (version) and get this error. any tips > > > > would be great! > > > > > my models: location has_many :versions > > > > > # view > > > > > <% form_for location do |location_form| %> > > > > <ul class="location"> > > > > <li><%= location_form.label location.section %></li> > > > > <li><%= location_form.label location.sub_section %></li> > > > > <li><%= location_form.label location.place_holder %></li> > > > > </ul> > > > > > <div class="content-area"> > > > > <% location.versions.each do |version| %> > > > > <div class="content" > > > > > <% location_form.fields_for version do |version_form| %> > > > > <%= version_form.label version.environment %> > > > > <%= version_form.text_area :content %> > > > > <% end %> > > > > </div> > > > > <% end %> > > > > <%= submit_tag %> > > > > </div> > > > > > <% end %> > > > > > #controller > > > > > def update > > > > @location = Location.find(params[:id]) > > > > -0tkTgdqk2elcQ7ALCyhmPw@public.gmane.org_attributes(params[:location]) #error: unknown > > > > attribute: version > > > > redirect_to( locations_path ) > > > > end > > > > > # the params > > > > > {"location"=>{"version"=>{"content"=>"hello human. glass robot want > > > > you to join Glass"}}, "commit"=>"Save changes", > > > > "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", > > > > "id"=>"2"} > > > > > -- > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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 use version and not :vorsion here: (since i believe i need to provide an object) location_form.fields_for version do |version_form| could it be related to the issue? On Apr 7, 6:17 pm, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I already have this: > > has_many :versions, :dependent => :destroy > accepts_nested_attributes_for :versions > > On Apr 7, 11:15 am, Nicolas Iensen <nicolas.ien...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Oren, > > > Try this "accepts_nested_attributes_for :versions" in the location.rb > > file. > > > Cheers! > > > On Apr 7, 1:30 am, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > ActiveRecord::UnknownAttributeError in LocationsController#update > > > > unknown attribute: version > > > > RAILS_ROOT: /home/oren/misc/projects/borderstylo/content > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > active_record/base.rb:2746:in `attributes='' > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > active_record/base.rb:2742:in `each'' > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > active_record/base.rb:2742:in `attributes='' > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > active_record/base.rb:2628:in `update_attributes'' > > > /home/oren/misc/projects/borderstylo/content/app/controllers/ > > > locations_controller.rb:29:in `update'' > > > > On Apr 7, 3:31 am, Ryan Waldron <r...-L2nCScK6t0HQT0dZR+AlfA@public.gmane.org> wrote: > > > > > Where''s the error message? > > > > > On Tue, Apr 6, 2010 at 8:49 PM, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I try to update a nested model (version) and get this error. any tips > > > > > would be great! > > > > > > my models: location has_many :versions > > > > > > # view > > > > > > <% form_for location do |location_form| %> > > > > > <ul class="location"> > > > > > <li><%= location_form.label location.section %></li> > > > > > <li><%= location_form.label location.sub_section %></li> > > > > > <li><%= location_form.label location.place_holder %></li> > > > > > </ul> > > > > > > <div class="content-area"> > > > > > <% location.versions.each do |version| %> > > > > > <div class="content" > > > > > > <% location_form.fields_for version do |version_form| %> > > > > > <%= version_form.label version.environment %> > > > > > <%= version_form.text_area :content %> > > > > > <% end %> > > > > > </div> > > > > > <% end %> > > > > > <%= submit_tag %> > > > > > </div> > > > > > > <% end %> > > > > > > #controller > > > > > > def update > > > > > @location = Location.find(params[:id]) > > > > > -0tkTgdqk2elcQ7ALCyhmPw@public.gmane.org_attributes(params[:location]) #error: unknown > > > > > attribute: version > > > > > redirect_to( locations_path ) > > > > > end > > > > > > # the params > > > > > > {"location"=>{"version"=>{"content"=>"hello human. glass robot want > > > > > you to join Glass"}}, "commit"=>"Save changes", > > > > > "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", > > > > > "id"=>"2"} > > > > > > -- > > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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.
This is how I did my nested forms (actually I have 3 forms nested): <% form_for [@resource, @validity] do |f| %> <% f.fields_for :timesheets do |t| %> <% t.fields_for :values do |v| %> R$ <%= v.text_field :value, :maxlength=>10 %> <% end %> <% end %> <%= f.submit "Save" %> <% end %> resource has_many validities validity has_many timesheets timesheet has_many values On Apr 7, 3:21 pm, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I use version and not :vorsion here: (since i believe i need to > provide an object) > location_form.fields_for version do |version_form| > > could it be related to the issue? > > On Apr 7, 6:17 pm, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I already have this: > > > has_many :versions, :dependent => :destroy > > accepts_nested_attributes_for :versions > > > On Apr 7, 11:15 am, Nicolas Iensen <nicolas.ien...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi Oren, > > > > Try this "accepts_nested_attributes_for :versions" in the location.rb > > > file. > > > > Cheers! > > > > On Apr 7, 1:30 am, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > ActiveRecord::UnknownAttributeError in LocationsController#update > > > > > unknown attribute: version > > > > > RAILS_ROOT: /home/oren/misc/projects/borderstylo/content > > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > active_record/base.rb:2746:in `attributes='' > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > active_record/base.rb:2742:in `each'' > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > active_record/base.rb:2742:in `attributes='' > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > active_record/base.rb:2628:in `update_attributes'' > > > > /home/oren/misc/projects/borderstylo/content/app/controllers/ > > > > locations_controller.rb:29:in `update'' > > > > > On Apr 7, 3:31 am, Ryan Waldron <r...-L2nCScK6t0HQT0dZR+AlfA@public.gmane.org> wrote: > > > > > > Where''s the error message? > > > > > > On Tue, Apr 6, 2010 at 8:49 PM, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I try to update a nested model (version) and get this error. any tips > > > > > > would be great! > > > > > > > my models: location has_many :versions > > > > > > > # view > > > > > > > <% form_for location do |location_form| %> > > > > > > <ul class="location"> > > > > > > <li><%= location_form.label location.section %></li> > > > > > > <li><%= location_form.label location.sub_section %></li> > > > > > > <li><%= location_form.label location.place_holder %></li> > > > > > > </ul> > > > > > > > <div class="content-area"> > > > > > > <% location.versions.each do |version| %> > > > > > > <div class="content" > > > > > > > <% location_form.fields_for version do |version_form| %> > > > > > > <%= version_form.label version.environment %> > > > > > > <%= version_form.text_area :content %> > > > > > > <% end %> > > > > > > </div> > > > > > > <% end %> > > > > > > <%= submit_tag %> > > > > > > </div> > > > > > > > <% end %> > > > > > > > #controller > > > > > > > def update > > > > > > @location = Location.find(params[:id]) > > > > > > -0tkTgdqk2elcQ7ALCyhmPw@public.gmane.org_attributes(params[:location]) #error: unknown > > > > > > attribute: version > > > > > > redirect_to( locations_path ) > > > > > > end > > > > > > > # the params > > > > > > > {"location"=>{"version"=>{"content"=>"hello human. glass robot want > > > > > > you to join Glass"}}, "commit"=>"Save changes", > > > > > > "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", > > > > > > "id"=>"2"} > > > > > > > -- > > > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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.
It works now. I had 2 loops and had to remove the external one: <% location.versions.each do |version| %> fields_for already create a loop on the children, so there is no need for another loop. thanks! On Apr 8, 11:36 am, Nicolas Iensen <nicolas.ien...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This is how I did my nested forms (actually I have 3 forms nested): > > <% form_for [@resource, @validity] do |f| %> > <% f.fields_for :timesheets do |t| %> > <% t.fields_for :values do |v| %> > R$ <%= v.text_field :value, :maxlength=>10 %> > <% end %> > <% end %> > <%= f.submit "Save" %> > <% end %> > > resource has_many validities > validity has_many timesheets > timesheet has_many values > > On Apr 7, 3:21 pm, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I use version and not :vorsion here: (since i believe i need to > > provide an object) > > location_form.fields_for version do |version_form| > > > could it be related to the issue? > > > On Apr 7, 6:17 pm, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I already have this: > > > > has_many :versions, :dependent => :destroy > > > accepts_nested_attributes_for :versions > > > > On Apr 7, 11:15 am, Nicolas Iensen <nicolas.ien...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Oren, > > > > > Try this "accepts_nested_attributes_for :versions" in the location.rb > > > > file. > > > > > Cheers! > > > > > On Apr 7, 1:30 am, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > ActiveRecord::UnknownAttributeError in LocationsController#update > > > > > > unknown attribute: version > > > > > > RAILS_ROOT: /home/oren/misc/projects/borderstylo/content > > > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > > active_record/base.rb:2746:in `attributes='' > > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > > active_record/base.rb:2742:in `each'' > > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > > active_record/base.rb:2742:in `attributes='' > > > > > /opt/ruby-1.8.7-p72/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/ > > > > > active_record/base.rb:2628:in `update_attributes'' > > > > > /home/oren/misc/projects/borderstylo/content/app/controllers/ > > > > > locations_controller.rb:29:in `update'' > > > > > > On Apr 7, 3:31 am, Ryan Waldron <r...-L2nCScK6t0HQT0dZR+AlfA@public.gmane.org> wrote: > > > > > > > Where''s the error message? > > > > > > > On Tue, Apr 6, 2010 at 8:49 PM, oren <orengo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I try to update a nested model (version) and get this error. any tips > > > > > > > would be great! > > > > > > > > my models: location has_many :versions > > > > > > > > # view > > > > > > > > <% form_for location do |location_form| %> > > > > > > > <ul class="location"> > > > > > > > <li><%= location_form.label location.section %></li> > > > > > > > <li><%= location_form.label location.sub_section %></li> > > > > > > > <li><%= location_form.label location.place_holder %></li> > > > > > > > </ul> > > > > > > > > <div class="content-area"> > > > > > > > <% location.versions.each do |version| %> > > > > > > > <div class="content" > > > > > > > > <% location_form.fields_for version do |version_form| %> > > > > > > > <%= version_form.label version.environment %> > > > > > > > <%= version_form.text_area :content %> > > > > > > > <% end %> > > > > > > > </div> > > > > > > > <% end %> > > > > > > > <%= submit_tag %> > > > > > > > </div> > > > > > > > > <% end %> > > > > > > > > #controller > > > > > > > > def update > > > > > > > @location = Location.find(params[:id]) > > > > > > > -0tkTgdqk2elcQ7ALCyhmPw@public.gmane.org_attributes(params[:location]) #error: unknown > > > > > > > attribute: version > > > > > > > redirect_to( locations_path ) > > > > > > > end > > > > > > > > # the params > > > > > > > > {"location"=>{"version"=>{"content"=>"hello human. glass robot want > > > > > > > you to join Glass"}}, "commit"=>"Save changes", > > > > > > > "authenticity_token"=>"l59NxAeIeHnvaVt+1xQV2e9NpDIS8nPpQ4RY+hU0k7w=", > > > > > > > "id"=>"2"} > > > > > > > > -- > > > > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > > > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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.