Reputation: 26758
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
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