rails devise Completed 401 Unauthorized && can't verify csrf token authenticity

13 篇文章 0 订阅

最近做项目的时候,由于时间紧,做得太快,没注意细节,导致一些错误.

11.05更新: 偶尔又会出现问题,清理历史记录后就好了!!!

 

1.can't verify csrf token authenticity

google了很久之后通过

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  # protect_from_forgery with: :exception
  protect_from_forgery with: :null_session # with: :exception 改为 with: :null_session

  before_action :authenticate_user!
end

 

2.这样解决后,又遇到Completed 401 Unauthorized, 情景就是登陆后又调到登陆页面

        <p class="notice"><%= notice %></p>

        <p class="alert"><%= alert %></p>
        <% flash.each do |name, msg| %>
            <%= content_tag :div, msg, class: "alert alert-info" %>
        <% end %>

 这里就是所有的问题所在

        <% flash.each do |name, msg| %>
            <%= content_tag :div, msg, class: "notice alert alert-info" %>
        <% end %>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值