Skip to content

Instantly share code, notes, and snippets.

@bartolsthoorn
Created March 3, 2011 12:04
Show Gist options
  • Save bartolsthoorn/852669 to your computer and use it in GitHub Desktop.
Save bartolsthoorn/852669 to your computer and use it in GitHub Desktop.
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"7dsqpiKslrOcAL+OB1RRhwYpikMn1s9AtBvRWsh2kpA=",
"work"=>{"name"=>"dsfsdfd",
"categorization_attributes"=>{"1"=>"1",
"3"=>"1"},
"description"=>"dsfsdffdfd"},
"commit"=>"Update Work",
"id"=>"5"}
def update
@work = Work.find(params[:id])
params[:categorization_attributes].each do |k, v|
puts "#{k} and #{v}"
end
respond_to do |format|
if @work.update_attributes(params[:work])
format.html { redirect_to(admin_work_url(@work), :notice => 'Work was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @work.errors, :status => :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment