问题
I have installed the will_paginate-bootstrap gem to use bootstrap style pagination. I have this in my view:
<%= will_paginate @mylist, renderer: BootstrapPagination::Rails %>
but it returns this error
uninitialized constant ActionView::CompiledTemplates::BootstrapPagination
回答1:
If you have successfully bundle all the gems then it should work like this.
<%= will_paginate @mylist, :renderer => BootstrapPagination::Rails %>
Please make sure you have restarted the server after installing the gem.
回答2:
If you use gem will_paginate-bootstrap with 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.
This is right for rails 3.X or earlier:
gem 'will_paginate-bootstrap', group: :assets
It must be outside of any groups (on rails 4.0 and later):
gem 'will_paginate-bootstrap'
回答3:
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.
回答4:
Just using will_paginate
and creating your own render works fine.
For bootstrap 4,throw this code into config/initializers/will_paginate.rb
Then, the code below into 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
回答5:
Try to update 'bootstrap-will_paginate' in Gemfile to '0.0.10'
gem 'bootstrap-will_paginate', '0.0.10'
and use <%= will_paginate @mylist%>
it helped to me
来源:https://stackoverflow.com/questions/21037955/uninitialized-constant-actionviewcompiledtemplatesbootstrappagination