Search code examples
ruby-on-railsruby-on-rails-4fields-for

Fields_for for nested resource


Here is my nested resource

  resources :hotels do
    resources :roomtype, :reservations
  end

What I would like to do is to list room types on the reservation form and determine the amount of rooms I wish to book. I have tried accept_nested_attributes_for to no avail. I can't seem to succeed to create proper a working fields_for form within the reservation form.

specs: rails 4.1, ruby 2.1


Solution

  • Rails 4 uses strong params. Update your model_params method of your Controller to accept nested attributes. Here is a good explanation.