Pagination issue: `map' : undefined method 'existent' - ruby-on-rails

I just installed the will_paginate, 3.0.7 and bootstrap-will_paginate, 0.0.10 gem and when i call the following to get my articles paginated
def index
#articles = Article.paginate(page: params[:page], per_page: 5)
end
I get the following error upon attempting to launch the localhost server
/Users/Jack/.rvm/gems/ruby-2.3.1#global/gems/activesupport-5.0.0.1/lib/active_support/i18n_railtie.rb:45:in `map': undefined method `existent' for #<String:0x007fd4a2bfa5d0> (NoMethodError)
Did you mean? extend
What's going wrong?

This was an issue with earlier version of will_paginate with Rails 5.
You need to update your will_paginate gem to use latest updated one which is:
gem 'will_paginate', '3.1.5'
This issue has been fixed with this merge:
https://github.com/mislav/will_paginate/pull/450

Related

solidus_searchkick - undefined method `deep_symbolize_keys'

I am using Solidus and I want to implement a better search wiht elasticsearch, I'm using solidus_searchkick to do that. But I get the following error:
undefined method 'deep_symbolize_keys' for #<ActionController::Parameters:0x0000556eae99cda8>
At Spree::HomeController#index, that has:
Spree::HomeController.class_eval do
def index
#searcher = build_searcher(params.merge(include_images: true))
#products = #searcher.retrieve_products
#taxonomies = Spree::Taxonomy.includes(root: :children)
end
end
I have NOT changed anything at Solidus' search options.
I get this error right after I run 'bundle install', installs everything just fine.
Then, I run 'rails s' and I get this error when I try to get my home or any other page that shows me any product.
Versions:
Rails: 5.1.6
Ruby: 2.5.1
solidus_searchkick: 0.3.4
Solidus: 2.5.0
This is an issue with the deprecated method deep_symbolize_keys in Rails 5.1. I just submitted a Pull Request for the solidus_searchkick gem. You can find it here https://github.com/elevatorup/solidus_searchkick/pull/6/files
If you point your solidus_searchkick gem to that branch it will work.

Kaminari - undefined local variable or method `page' for

I was using will_paginate for pagination on my site but as we're using Active Admin I decided to change it to kaminari to avoid any of the conflict issues between the two. I removed will_paginate from the gem file and added kaminari, restarted the rails server and ran bundle install but I'm getting errors which suggest it has not been installed properly:
undefined local variable or method `page' for <SearchController:0x007fd546587140>
Rails version: 5
Gemfile:
gem 'kaminari', '~> 0.16.3'
#gem 'will_paginate', '~>3.1.6'
Controller:
...
#properties = #properties.page(page[:params]).per(9)
Not sure what the issue is?
There is no object page in your controller...
#properties = #properties.page(page[:params]).per(9)
I think what you wanted to do was...
#properties = #properties.page(params[:page]).per(9)

Will_paginate gem is not installing - Rails 4

for something reason will_paginate is not installed.
i have put the line
gem 'will_paginate', '~>3.0.6'
in my gemfile,
i even ran "gem install will_paginate" in the console.
it says installed sucessfully but using the instructions to check if will_paginate is indeed install returns false nil
reference:
>> defined? WillPaginate
>> ActiveRecord::Base.respond_to? :paginate
If any of these lines return nil/false, will_paginate has not properly loaded in your app.
and i get this error when implemented
undefined method `total_pages' for #<Post::ActiveRecord_Relation:0x007fa40773bc18>
UPDATE:
I specifically stated in my gemfile to install version 3.0.5 not the latest version(3.0.7) and the gem is loaded properly. BUT the error with the total_pages still remains.
more info:
controller:
#posts = Post.paginate(:page => params[:page])
view:
<%= will_paginate #posts %>
UPDATE 2:
FIXED the error (had a typo) BUT i cannot see visually the gem anywhere on the page.

Why will_paginate not loaded in rails 3.2.8 engine?

Here is the code in our index to return #customers:
#customers = Customerx::Customer.where(:active => true).order("since_date DESC, id DESC").paginate(:per_page => 30, :page => params[:page])
It causes error of below:
undefined method `paginate' for #<ActiveRecord::Relation:0x6b88960>
In debug, ActiveRecord::Base.respond_to? :paginate returns false. It seems to us that the will_paginate was not loaded, even though will_paginate (3.0.3) was returned with gem list.
What could be wrong with the code?
The problem was fixed by adding gem will_paginate in engine's gemfile, even though gem will_paginate is in gemspec for the rails engine. The problem was caused by gem paginate was not loaded as ActiveRecord::Base.respond_to? :paginate returned false.
Here is a post that is somewhat similar to the problem here.
Rails Engine - Gems dependencies, how to load them into the application?
even I used to get this error, so I tried page method...use
#customers = Customerx::Customer.where(:active => true).order("since_date DESC, id DESC").page(params[:page]).per_page(30)

undefined method `page' for #<ActiveRecord::Relation:0xaadc8d4>

Im trying to install Kaminari pagination on rails 3 with adminpanel RailsAdmin, but I get this error:
NoMethodError in ShowsController#
undefined method `page' for # < ActiveRecord::Relation:0xaadc8d4>
Do you also have the gem "will_paginate" in use?
Check the file Gemfile.lock to see if you have this gem in use as well:
grep will_paginate Gemfile.lock
If that's the case, all you have to do is to create the file "config/initializers/kaminari.rb" and write this content on the file:
Kaminari.configure do |config|
config.page_method_name = :per_page_kaminari
end
that should fix the issue
In my case I forgot to add the kaminari gem to my Gemfile :facepalm:

Resources