As I have written in the title I get the following error when I try to click on my games page.
This is what I have in my games_controller:
def email
respond_to do |format|
user = @game.user
email = user.email
g = GameTrade.game_interest(user)
g.deliver
format.html { redirect_to root_url }
format.json { render json: @game }
end
end
and this is what I have in the show.html.erb
<%= button_to "Send Email", :action => 'email'%>
in my routes page I do have the line resources :games
“email” is not a standard route for a resource, so you’ll need to add a route for it. Ideally this would be a POST request, since following that link (button) causes changes to occur. Finally, you should really stick to using the url helpers rather than specifying actions as they make your code a little brittle.
Try something like this in your routes.rb:
Then in your view, generate your button like so:
You’ll then need to find the game in your email action in the usual way before you can do anything with it: