To overcome this error replace your match
statement with a get
statement
Replace:
match 'calculate' => 'index#calculate'
With:
get 'calculate' => 'index#calculate'
The reason for Rails suggesting that you use get
instead of the more generic match
is improving security by forcing you to make a conscious api design decision. A GET request is different from a POST request. A POST means 'change'; that request changes something, it modifies the system. A GET means 'give this page'. It does not change anything.
I assume your endpoint returns the result of some sort of calculation. You may argue that since the calculation does not change anything, a GET request is the way to go. You can also argue that this endpoint won't always return the same value for the same input (maybe?) in that case you may want to say that this is a POST, since you are not getting a unique resource.
I believe this is test app that you are making. Depending on what aspect of rails do you want to focus your learning on you may want to choose one, implement both and see what changes, or just flip a coin :)
The match
method used to work in the way you used it, but since rails 4 this was changed to require this explicitness.
Docs: http://guides.rubyonrails.org/routing.html#http-verb-constraints