uninitialized constant ActionView::CompiledTemplates::BootstrapPagination
Asked Answered
O

5

7

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
Orvieto answered 10/1, 2014 at 6:53 Comment(0)
D
13

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.

Dense answered 10/1, 2014 at 9:38 Comment(4)
Restarting the server did it for me. Thanks.Orvieto
This did not work for me. It works locally but on the server I am getting the same error.Dinin
did you restart the server ? try restarting the httpd service if you are running appacheOrvieto
I was using 'bootstrap-will_paginate' rather than 'will_paginate-bootstrap'. Fixing that and restarting the server did the trick.Starvation
B
1

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'
Brunei answered 6/6, 2015 at 12:25 Comment(0)
D
0

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.

Disquieting answered 13/11, 2014 at 15:44 Comment(0)
C
0

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
Crete answered 19/5, 2017 at 17:11 Comment(0)
O
-1

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

Oxus answered 24/12, 2014 at 21:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.