twitter-bootstrap 未初始化的常量 ActionView::CompiledTemplates::BootstrapPagination
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21037955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
uninitialized constant ActionView::CompiledTemplates::BootstrapPagination
提问by Sayed Jalil Hassan
I have installed the will_paginate-bootstrap gem to use bootstrap style pagination. I have this in my view:
我已经安装了 will_paginate-bootstrap gem 来使用引导式分页。我的看法是这样的:
<%= will_paginate @mylist, renderer: BootstrapPagination::Rails %>
but it returns this error
但它返回这个错误
uninitialized constant ActionView::CompiledTemplates::BootstrapPagination
回答by Sabyasachi Ghosh
If you have successfully bundle all the gems then it should work like this.
如果你已经成功地捆绑了所有的 gem,那么它应该像这样工作。
<%= will_paginate @mylist, :renderer => BootstrapPagination::Rails %>
Please make sure you have restarted the serverafter installing the gem.
请确保您在安装 gem 后重新启动了服务器。
回答by Fa11enAngel
If you use gem will_paginate-bootstrapwith rails 4.0 or later, you must have it available on all stages. See Rails Upgrade Guide 3.2 to 4.0. Before Rails 4.0 this was fine, to have it only in assets.
如果您将 gem will_paginate-bootstrap与 rails 4.0 或更高版本一起使用,则必须在所有阶段都可用。请参阅Rails 升级指南 3.2 到 4.0。在 Rails 4.0 之前,这很好,只在资产中使用。
This is right for rails 3.X or earlier:
这适用于 rails 3.X 或更早版本:
gem 'will_paginate-bootstrap', group: :assets
It must be outside of any groups (on rails 4.0 and later):
它必须在任何组之外(在 rails 4.0 及更高版本上):
gem 'will_paginate-bootstrap'
回答by daino3
Just using will_paginateand creating your own render works fine.
仅使用will_paginate和创建自己的渲染效果很好。
For bootstrap 4,throw this codeinto config/initializers/will_paginate.rb
对于引导程序 4,将此代码放入config/initializers/will_paginate.rb
Then, the code below into application_helper.rb:
然后,下面的代码变成application_helper.rb:
def will_paginate(collection_or_options = nil, options = {})
if collection_or_options.is_a? Hash
options, collection_or_options = collection_or_options, nil
end
unless options[:renderer]
options = options.merge renderer: WillPaginate::ActionView::BootstrapLinkRenderer
end
super *[collection_or_options, options].compact
end
And finally, call in the view like so:
最后,像这样调用视图:
nav aria-label="blah"
= will_paginate @items
回答by MustModify
In my Gemfile, I had will_paginate-bootstrap in my "assets" group... but it isn't just a set of assets. That class needs to be around in production. Moving it out of the assets group resolved this issue for me.
在我的 Gemfile 中,我的“资产”组中有 will_paginate-bootstrap ......但它不仅仅是一组资产。该类需要在生产中存在。将它移出资产组为我解决了这个问题。
回答by Victor
Try to update 'bootstrap-will_paginate' in Gemfile to '0.0.10'
尝试将 Gemfile 中的“bootstrap-will_paginate”更新为“0.0.10”
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-will_paginate', '0.0.10'
and use <%= will_paginate @mylist%>
并使用 <%= will_paginate @mylist%>
it helped to me
它对我有帮助

