max pleaner
max pleaner

Reputation: 26758

cannot bring up show page

This is the button that should bring up the show page edit - changed

 <%= button_to 'Show', post_path(p) %>

This does bring up a button but I get an error when I click it:

No route matches [POST] "/posts/3"

I am confused why a POST request is being sent. (Note "post_path" refers to a "Post" controller/model).

In my routes I have

resources :posts

The button is on the index page and I have an iterator to make an edit button for each Post. Here is my "show" action:

def show
        @post = Post.find(params[:id])
end

Thanks for your help.

*edit: the code is here: https://github.com/MaxPleaner/feature_tester*

Upvotes: 0

Views: 33

Answers (1)

sevenseacat
sevenseacat

Reputation: 25029

Rails will construct a form around button elements so that they work properly, and forms by default will use method: :post.

If it's just a link to the show page, it should be a link. You can style the link to look like a button if you really wish.

Upvotes: 2

Related Questions