Twitter bootstrap 错误:将生成器与Pundit一起使用时,未初始化的常量WillPaginate::ActionView(NameError)
我的应用程序使用CanCan,但现在我想切换到Pundit。我向Gemfile添加了Pundit,删除了CanCan,运行了Twitter bootstrap 错误:将生成器与Pundit一起使用时,未初始化的常量WillPaginate::ActionView(NameError),twitter-bootstrap,cancan,pundit,Twitter Bootstrap,Cancan,Pundit,我的应用程序使用CanCan,但现在我想切换到Pundit。我向Gemfile添加了Pundit,删除了CanCan,运行了bundle,然后在尝试运行生成器(rails g Pundit:install)时,我得到了错误: ...config/initializers/bootstrap_link_renderer.rb:1:in `<top (required)>': uninitialized constant WillPaginate::ActionView (NameErr
bundle
,然后在尝试运行生成器(rails g Pundit:install
)时,我得到了错误:
...config/initializers/bootstrap_link_renderer.rb:1:in `<top (required)>': uninitialized constant WillPaginate::ActionView (NameError)
…config/initializers/bootstrap\u link\u renderer.rb:1:in`':未初始化常量WillPaginate::ActionView(NameError)
这是我的应用程序\u controller.rb文件:
class ApplicationController < ActionController::Base
include Pundit
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
def configure_permitted_parameters
devise_parameter_sanitizer.for(:account_update) << :avatar
end
def after_sign_in_path_for(resource)
topics_path
end
end
class ApplicationController
暂时尝试删除配置/初始化器/bootstrap\u link\u renderer.rb
以查看问题是否仍然存在。这可能与CanCan->Pundit的变化无关 删除链接渲染器文件使其工作——所以现在我必须确保能够使用引导!谢谢。:)
class BootstrapLinkRenderer < WillPaginate::ActionView::LinkRenderer
def html_container(html)
tag(:ul, html, container_attributes)
end
def page_number(page)
tag :li,
link(page, page, rel: rel_value(page)),
class: ('active' if page == current_page)
end
def gap
tag :li,
link(super, '#'),
class: 'disabled'
end
def previous_or_next_page(page, text, classname)
tag :li, link(text, page || '#')
end
def previous_page
num = @collection.current_page > 1 && @collection.current_page - 1
previous_or_next_page(num, '«', 'previous_page')
end
def next_page
num = @collection.current_page < total_pages && @collection.current_page + 1
previous_or_next_page(num, '»', 'next_page')
end
end