Reputation: 11
Help! My error message is saying : ActionController::InvalidAuthenticityToken. Is there something wrong with my interpolation of form_authenticity_token?
application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
application_helper.rb
module ApplicationHelper
def auth_token
"<input
type='hidden'
name='authenticity_token
value='#{form_authenticity_token}'
/>".html_safe
end
end
Upvotes: 0
Views: 38
Reputation: 1033
Depending on what version of Rails you're using (but let's say it's 4 or 5), all you should need to get the tokens working is:
# In the html head section of app/views/layouts/application.erb
<%= csrf_meta_tags %>
You should not need the custom auth_token
helper method you've created!
Upvotes: 2