Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 920437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:42:49+00:00 2026-05-15T18:42:49+00:00

Im trying to update some nested params from a form. I can see that

  • 0

Im trying to update some nested params from a form. I can see that the parameters im getting from the form is correct, however the database dont get updated.

the view

<% form_for @order do |f| %>
  <% f.fields_for :itemgroups do |ff, i| %>
    <% ff.fields_for :items do |fff| %>
      <%= ff.text_field :text, :id => "textField", :disabled => true %>
      <%= ff.text_field :price, :class => "priceField", :disabled => true %>
      <%= fff.check_box :registered, :class => i %>
    <% end %>
  <% end %>
  <%= submit_tag 'Save', :disabled_with => "Saving..." %>
<% end %>

Itemgroup class

class Itemgroup < ActiveRecord::Base
  belongs_to :order
  has_many :items, :dependent => :destroy
  has_one :kind

  accepts_nested_attributes_for :items, :kind
end

Order class

class Order < ActiveRecord::Base
  has_many :itemgroups, :dependent => :destroy
  has_many :items, :through => :itemgroups, :dependent => :destroy
  has_many :kinds, :through => :itemgroups

  accepts_nested_attributes_for :itemgroups, :allow_destroy => true

  validates_associated :itemgroups, :items ,:kinds
end

The important part of the controller.

def update
  @order = Order.find(params[:id])

  if @order.update_attributes(params[:order])
    flash[:notice] = 'Order was successfully edited.'
    redirect_to(@order)
  else
    flash[:notice] = 'An error occured.'
    render(:action => :edit)
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:42:50+00:00Added an answer on May 15, 2026 at 6:42 pm

    Fixed the problem!

    class Order < ActiveRecord::Base
      has_many :itemgroups, :dependent => :destroy
      has_many :items, :through => :itemgroups, :dependent => :destroy
      has_many :kinds, :through => :itemgroups
    
      accepts_nested_attributes_for :itemgroups, :allow_destroy => true
    
      # validates_associated :itemgroups, :items ,:kinds
    end
    

    the validates_associated line was removed. Then it worked

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update some local access databases from a web database. When
I am trying to update some hibernate code that was written by someone else
Hi I am trying to update a div with some html from another div.
I'm trying to update the display brightness from a widget but i have some
i'm trying to make a ajax update in prototype with some values from a
Trying to update some repositories on Debian Etch installation and getting the following errors
I have an otherwise functioning rails project where I'm trying to update some form
I'm trying to programme an Android app that will update some TextViews as I
I am trying to update some rows in an oracle Database, using an OLEDB
Trying to update some old code from live() to use on() and something is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.