I want to use the link to function to point to a form.
i.e <%= link_to ‘Reports’, ‘/reports/index.html.erb’ %>
But this gives me a error saying no route matches ‘/reports/index.html.erb.
Thanks,
Ramya.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Rails doesn’t like having the document format in the URL unless it’s necessary (like when one action can handle multiple request formats). If you have
reports/index.html.erb, the route to it would look like one of these:Then your link would be:
or
If you really wanted to have the
.html, you could probably do it like this:or
But the
.htmlis meaningless in the first case and unnecessary in the second. I don’t recommend doing it this way, as it’s not standard Rails practice.I highly recommend you read this tutorial on Routing, at least the first few sections, before you move forward. It’s an absolutely essential part of Rails, and if you don’t understand how it works, you will never be a productive Rails programmer.