-1

I have an application with a Bill ActiveRecord model. I want to include on a page a link "Back to bill", which will send the user to the "show" page of that bill. Right now I have

<% link_to "Back to bill", bill_url(bill_id) %>

Where bill_id is the correct id of the bill I want to show.

When I click on the link, I am redirected to the correct url (as displayed in the browser). However, regardless of what the bill_id is, the bill which is shown is only the first bill record in the "bills" table in my database.

Why is the redirect happening incorrectly, and what method should I use to correctly render the bill that matches the generated URL?

Leland Reardon
  • 135
  • 2
  • 12

1 Answers1

0

Make sure your show action in BillsController has the following:

@bill = Bill.find(params[:id])
Rigo
  • 523
  • 1
  • 8
  • 22