i couldn’t find a game without a game id when i searched

So you’re getting that error because params[:id] doesn’t exist when you are reaching the def search method. Calling .find on something will always result in an exception being raised unless something is found. If this is intended then cool otherwise change it to .find_by id: params[:id]. This would cause your @games variable to be nil.

I think that you are trying to search on params[:game]. In which case you may have to use @games = Game.find_by game: params[:game]

You can see what params are being passed to your method in your logs.. but it may be worth attaching a debugger; such as byebug to the top of your method so you can see what params are present.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top