In my routes file I have:
match 'graphs/(:id(/:action))' => 'graphs#(:action)'
and I would like to match this if it is GET request (working) or POST request (not working)
I know that I can declare POST request inside a resource using:
post '/' => :show, :on => :member
But how can I do that for a match ?
Thanks.
In some applications, the HTTP methods GET and POST can be used interchangeably. For example, the application may expect a POST request, and the frontend will also send the data in a POST request, but if the request is tampered with, the data will also be accepted in a GET request.
HTTP POST requests supply additional data from the client (browser) to the server in the message body. In contrast, GET requests include all required data in the URL.
The GET request is marginally less secure than the POST request. Neither offers true "security" by itself; using POST requests will not magically make your website secure against malicious attacks by a noticeable amount. However, using GET requests can make an otherwise secure application insecure.
GET can't be used to send word documents or images. GET requests can be used only to retrieve data. The GET method cannot be used for passing sensitive information like usernames and passwords. The length of the URL is limited.
if you want for both POST and GET
match 'graphs/(:id(/:action))' => 'graphs#(:action)', :via => [:get, :post]
Edit
defaults can be set as following
match 'graphs/(:id(/:action))' => 'graphs#(:action)', :via => [:get, :post],
:defaults => { :action => "index" }
and the syntax seems to be correct
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With