user2239655
user2239655

Reputation: 840

Randomly get routing error

I noticed in my logs that I get following error and this error occurs randomly couple times per day:

ActionController::RoutingError (No route matches [GET] "/pos/2312/send"):

This is my rake routes output:

rake routes | grep pos

export_positions_entry POST /pos/:id/send(.:format) position_entries#send    

I don't know why it occurs randomly. How can I investigate it?

Edit:

I use following code to call that action:

%li= link_to "Send", export_position_path(entry)

And here is correct request from logs:

[2014-06-25] method=POST path=/pos/5454/send format=json controller=position action=send status=200 params={something} 

But randomly it send GET.

Upvotes: 1

Views: 168

Answers (2)

Brad Werth
Brad Werth

Reputation: 17647

It appears you only allow POST, but that request is GET....

What is probably happening is that the user is POSTing the form a time or two, and getting errors, or something. This is making their URL change (to /pos/2312/send, for example). Then, they are probably just hitting enter in the URL bar, to produce your phantom GET request. This is one of my issues with rails default REST routes, as provided by resources, and I usually change the update post to go to the edit page (or, somewhere with a GET variant, at least) for that very reason.

Upvotes: 3

Pandya M. Nandan
Pandya M. Nandan

Reputation: 682

Your routes are configured for a POST request, however you are attempting to visit that page using a GET request.

Either change your config/routes.rb file to collect GET request or send a post request for the url. **If you are using this url for a submit action for a form, use 'method: post'

Upvotes: -1

Related Questions