0
votes

I have gone through railscasts video #198 Edit Multiple Individually and #165 Edit Multiple (revised) to edit multiple individually. But how do I get them to work on same page so that the value that are checked gets saved with modified data?

I have a model Car with following relation.

  has_many :cars_extra_products
  has_many :extra_products, through: :cars_extra_products

Also, the ExtraProduct model has relation as:

  has_many :cars_extra_products
  has_many :cars, through: :cars_extra_products

And the CarsExtraProduct model with relation:

  belongs_to :extra_product
  belongs_to :car

How to display all the extra product in same page, so that owner can pick list of products they want and modify them individually in same page and save them under cars_extra_products with attibute extra_product_id, price, mode, rv_id?

Example:

enter image description here

I would just loop the association and use fields_for to perform a put request with the correct nested attributes - Fabrizio Bertoglio
Will looping through the association show data from ExtraProduct? The use case here is to firstly show all data from ExtraProduct model. And when user checks the particular extra_product and if changes the value of price or mode, then save it on rvs_extra_products join table. How can that be solved? - Code father