I have a controller promos. When the edit action is called the
following error is given -
Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id
For simplicity the controller and view looks like this:
It's not the instance variable name, it's that that instance variable
has a nil value.
What was the id parameter in the request? I suspect that the find
failed to find a record with that id, which would cause it to return
nil.
Your controller should be doing something like:
def edit
unless(@promo = Promo.find(params[:id]))
# There was no promo with that id
# Perform some appropriate error action
# Which might involve setting the flash with an error msg
# and redirecting somewhere
end
end