简体   繁体   中英

Getting “No route matches [GET]” error in spite of defining my link_to as a “post”

I have the following in my controller:

view_context.link_to("undo", revert_version_path(@course.versions.last), :method => :post)

And the following route:

post 'versions/:id/revert' => 'versions#revert', as: "revert_version"

I get the following error: No route matches [GET] "/versions/16/revert"

The error does not occur if I change the method type to get

PS: I'm following this RailsCast .

Are you sure that you didn't disable javascript? From link_to documentation:

"Note that if the user has JavaScript disabled, the request will fall back to using GET"

It seems that method: :post is not being respected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM