I have the following code in the routes.rb file.
resources :users do member do get :following,:followers end collection do put :activate_email end end
And I have a user email activation link:
<%= link_to "Activate",activate_email_users_url(email_token: @user.email_token),method: :put %>
When I click on the activation link, this is the URL that is generated
http://localhost:3000/users/activate_email?email_token=WWNvMN-r_lXgovrQiDlSSQ
Update: Good, so I think I know what the problem is. When I look at the activation email html source in my gmail that contains link_to, no
data-method = 'put'
. So this is a problem. It always sends a default GET request instead of PUT. This is my user_mailer / registration_confirmation.html.erb file
<%= javascript_include_tag "application" %> </head>
Please click on the following link to activate your email address. <% = link_to "Activate", activate_email_users_url (email_token: @ user.email_token), method :: put%>
This results in the following error:
undefined method `protect_against_forgery? ' for #
So, the code <% = javascript_include_tag "application"%>
causes this error. Is there any way around this?