0

I feel like this should be simple but for some reason I can't figure this out. I just want to add the edit and delete actions to the navbar when a user is on the show page.

I'm getting a route error saying the edit action doesn't exist on the homepage or the new page, here's my code:

layouts/application.html.haml

.nav-collapse
   %ul.nav.pull-right
      %li= link_to "All Articles", root_path
      %li= link_to "New Article", new_article_path
      - if current_page?(@article)
        %li= link_to 'Edit', edit_article_path
        %li= link_to 'Delete', { :action => :destroy, :id => @article.id }, :method => :delete, :confirm => 'Are you sure?'
sacshu
  • 397
  • 9
  • 20

1 Answers1

0

The link to edit page should have an id (or something relative) of the object you want to edit. So, the link helper should be written:

link_to 'Edit', edit_article_path(@article) # or explicitly (@article.id)

alup
  • 2,961
  • 1
  • 21
  • 12