ActiveRecordStore InvalidAuthenticityToken

I recently used a cookie repository and I want to go to the active records repository. However, I continue to receive an invalid authentication token. After deleting my cookies, I was able to access this page very well, but I do not want all my users to come to my page, get a huge error, and then find out that I want them to delete cookies.

So, I made a function called delete cookies:

  after_filter :delete_cookie
  def delete_cookie
    puts "deleting cookies"
    cookies.to_hash.each_pair do |k, v|
      puts k
      cookies.delete(k)
    end
  end

In the application controller, but it does not work correctly. I still see my cookie after visiting any page. I feel that there really should be a better solution, but I still cannot find anyone. Any clues?

+3
2

, , , AR cookie cookie ( ).

+1

application_controller.rb

protect_from_forgery # See ActionController::RequestForgeryProtection for details
-1

Source: https://habr.com/ru/post/1747803/


All Articles