我有一个rails应用程序,我打算升级到rails 5.我正在使用devise(v4.2.0)和rails(v5.0.0).正如设计README.md文件中所建议的那样,我尝试将prevent_from_forgery移到before_filter之上但仍然在我尝试登录或更新我的错误时出现错误ActionController::InvalidAuthenticityToken
我的Application Controller是
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, prepend: true
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end
end
Run Code Online (Sandbox Code Playgroud)
我的另一个BugController是
class BugsController < ApplicationController
protect_from_forgery prepend: true, with: :exception
before_action :authenticate_user!
before_action :set_bug, only: [:show, :edit, :update]
def update
respond_to do |format|
if @bug.update(bug_params)
format.html { redirect_to @bug, notice: 'Bug was successfully updated.' }
format.json { render :show, status: :ok, location: @bug }
else
format.html { …Run Code Online (Sandbox Code Playgroud) 在我的索引视图中,我有一个表(它使用 bootstrap 表排序 javascript 库对列进行排序)我正在使用 Rails 5。
所以现在当我点击 时 <%= link_to 'Products', products_path %>,javascript 没有加载,但是当我重新加载浏览器(ctrl + r)时,我看到表格排序开始工作。在查看 Chrome Developer 中的网络选项卡后,我可以看到这种情况发生,使用 link_to 看不到对 js 文件发出的任何请求,但当我重新加载时,js 文件可用。
我正在使用标准导轨结构
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
Run Code Online (Sandbox Code Playgroud)
我的猜测是由于涡轮链接而发生了一些事情,但我无法弄清楚
jquery ruby-on-rails twitter-bootstrap turbolinks ruby-on-rails-5