Search code examples
ruby-on-railsrouteslink-to

How to set an edit link?


I'm using Rails 4.0.10. I have a show and edit view for a model. The show url is just model/id, and the edit url is model/id/edit. What I can't figure out is how to create a link on the show page that redirects to the edit page.

Here's what I've tried so far:

<%= link_to "edit", model_edit_path(model) %>

Solution

  • The correct way is (swap model and edit around) :

    <%= link_to 'Edit', edit_model_path(model) %>