I have a 'transaction' model, controller and 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
(Because I have this line in my controller)
before_action :set_transaction, only: [:show, :edit, :update, :destroy])
and I also see this line in logs:
Request info
Request parameters
{"controller"=>"transactions", "action"=>"show", "id"=>"history"}
My full routes: routes.rb My full errors: error logs Why it is calling the 'show' action in my transaction controller?