undefined method `to_sym' for nil:NilClass

Hi,

When updating a ReferralProgram object that has nested Pages in it I get the error in the subject line.

Rails generates parameters that look like this:

{"pages_attributes"=>{"0"=>{"body"=>"blabla", "subject"=>"blabla", "id"=>"1"}}}

When the id parameter is removed like this:

{"pages_attributes"=>{"0"=>{"body"=>"blabla"}}}

The exception is not raised. Any ideas on this?

The relevant part that 'crashes' the form:

form.html.haml

I can't really test this right now but here's a thought:

- If you create a new ReferralProgram with new Pages there shouldn't be a Page ID in the params because these Pages don't exist yet (If you assign existing pages double check if a Page with that ID exists). - If I remember this correctly multiple nested objects have to be in an array in the params like:

"pages_attributes" => [ {"body"=>"blabla", "subject"=>"blabla"}, {"body" => "blublu", "subject"=>"blublu"} ]

Hope this helps a little! Simon

I was using the to-csv and fastercsv gem. When I commented them out of my environment.rb, the error disappeared. I don't know which gem was causing it, but not using either of them has fixed it for now. I will still need CSV export functionality, but now I can at least test if it doesn't break nested forms .. :slight_smile:

Thanks Simon!

Hi,

I'm facing the exact same error right now. Is there a solution to this issue?

I'd really like to use to-csv+fastercsv.

Let me know.

THX alot,

Thomas

Commander Johnson wrote: