I have transaction model, controller with view, which I created with rails generate. Now I need to add a single custom route of /transactions/history to my application to be handled by a controller def history:... end and render history.html.erb
So added this line in my routes.rb:
get '/transactions/history', to: 'transactions#history', as: 'transactions_history'
And this in my transactions_controller.rb:
def history
@transactions = Transaction.all
end
and created a history.htmk.erb in transactions->views
I also see this line when calling rake routes:
transactions_history GET /transactions/history(.:format) transactions#history
But when I request localhost:3000/transactions/history in my browser, it gives me the following error:
Couldn't find Transaction with 'id'=history
and I also see this line in logs:
Request info
Request parameters
{"controller"=>"transactions", "action"=>"show", "id"=>"history"}
Why it is calling the 'show' action in my transaction controller?
Aucun commentaire:
Enregistrer un commentaire