Hi there,
I’m running my app using rails 2.0.2.
When running the create method in my controller, I get the following
error:
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.[]
app/controllers/routes_controller.rb:39:in `create’
Parameters:
{“commit”=>“Create”,
“route”=>{“name”=>“testroute”},
“user_ids”=>[“1”,
“4”],
“heading_id”=>“0”
Here’s line 39 in the controller:
@route.users = User.find(@params[:user_ids]) if @params[:user_ids]
I don’t understand what’s going on here. The following works when I run
it in the console:
User.find([1,4])
I’m at a loss as to why this doesn’t work.
Can anyone help me here?
Thanks!