Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

Accepts Nested Attributes For

So accepts nested attributes is really about writing to an attribute of a class.

In my case a location belongs_to a user. I was then trying to set the location.street1 through the user, but it wouldn’t write. This is because it needs the accepts_nested_attributes method in the model.

If I want to manage questions through my surveys forms…
1
2
3
4
class Survey < ActiveRecord::Base
  has_many :questions, :dependent => :destroy
  accepts_nested_attributes_for :questions, allow_destroy: true
end

Railscast - min 6 javascript

destroy -> allow_destroy: true

Comments