Well the error is telling the truth, I have used the route name 'contact' twice, but one match is for a get request and the other for a post. I have been following the following tutorial for setting up Contact Form in Rails: http://matharvard.ca/posts/2011/aug/22/contact-form-in-rails-3/, and the author suggests adding the following to my routes file:
match 'contact' => 'contact#new', :as => 'contact', :via => :get
match 'contact' => 'contact#create', :as => 'contact', :via => :post
However that gives me the following error:
Invalid route name, already in use: 'contact' (ArgumentError)
Here is my own routes.rb file:
Fls::Application.routes.draw do
root 'welcome#index'
match 'contact' => 'contact#new', :via => :get
match 'contact' => 'contact#create', :as => 'contact', :via => :post
end
Do the following instead of above:
resource :contact, only: [:new, :create]
OR
get 'contact' => 'contact#new'
post 'contact' => 'contact#create', :as => 'contact'
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