small medium large xlarge

Generic-user-small
09 Dec 2009, 07:30
Chris Marzullo (2 posts)

I am using code based on recipe 13 and I have problems removing the last ‘task’

When I delete the last item using the javascript and then update the item I get the following error message and nothing gets deleted:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

I have the line in my update controller as instructed: params[:project][:existing_task_attributes] ||= {}

If I comment out that line it doesn’t barf. But also doesn’t delete the last task.

Screen shot 2016-02-29 at 16.55.11_pragsmall
14 Dec 2009, 18:27
Bob (6 posts)

do you have a blank object created? @project.tasks.build

Generic-user-small
17 Dec 2009, 20:20
Chris Marzullo (2 posts)

Thanks for responding Mikhailov!

I presume that build line goes in the controller? Or in the existing_task_attributes part in the model? The only place I see a reference to @project.tasks.build in the book is in the model under new_task_attributes.

Generic-user-small
12 Feb 2010, 04:44
Leigh Daniels (2 posts)

Chris,

I’m having the same problem. Have you found a solution? I’ve spent hours looking for one.

**Leigh

You must be logged in to comment