Nil object error - not under console

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:

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]

Should be @route.users = User.find(params[:user_ids]) if
params[:user_ids]

The current code is trying to use an instance variable name params

Best.
Mike

Should be @route.users = User.find(params[:user_ids]) if
params[:user_ids]

Well, that fixed it. The previous code I had did work, maybe when I
upgraded to rails 2.0 it stopped? This method doesn't get run much and
could have gone unnoticed.

Thanks so much for your help.

Jason

You're welcome Jason. You can check out this post for more detail on
@params vs. params http://weblog.rubyonrails.org/2006/4/25/use-params-not-params

Best.
Mike