Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with mongoid 5.0.1 #748

Closed
jakoss opened this issue Nov 4, 2015 · 13 comments
Closed

Problem with mongoid 5.0.1 #748

jakoss opened this issue Nov 4, 2015 · 13 comments

Comments

@jakoss
Copy link

jakoss commented Nov 4, 2015

Every time i want to use paginate i get error:

undefined method `with_default_scope' for {}:Hash

Even on simple code like this:

@news = News.order_by(created_at: 'desc').page params[:page]
@yuki24
Copy link
Member

yuki24 commented Nov 4, 2015

@NekroMancer could you provide a minimal example of code that replicates the bug?

@jakoss
Copy link
Author

jakoss commented Nov 4, 2015

I have model News like:

class News
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Slug

  mount_uploader :image, NewsImageUploader

  paginates_per 10

  field :title, type: String
  field :content, type: String
  field :image, type: String

  slug :title

  belongs_to :user
end

Any simple controller that uses paging like:

def news
    @news = News.order_by(created_at: 'desc').page params[:page] 
  end

When i comment out .page params[:page] everything works fine

@yuki24
Copy link
Member

yuki24 commented Nov 4, 2015

@NekroMancer I'm sorry, but what I meant by example was an single runnable ruby script that raises the exception you are seeing in your app. You can also write a test case that fails. Either way, we won't be able to fix it until you provide something we can run on our machine that replicates the error.

@dblock
Copy link
Contributor

dblock commented Nov 4, 2015

Try against HEAD please, Mongoid 5.x support has not been released in Kaminari, see #747

@dblock
Copy link
Contributor

dblock commented Nov 4, 2015

@NekroMancer I see you have Mongoid::Slug in there, upgrade to 5.1.1, see mongoid/mongoid-slug#197 and mongoid/mongoid-slug#198

@jakoss
Copy link
Author

jakoss commented Nov 6, 2015

I tried to install from HEAD, but:

Bundler could not find compatible versions for gem "kaminari":
  In Gemfile:
    kaminari (~> 0.12) ruby

    rails_admin (>= 0) x86-mingw32 depends on
      kaminari (~> 0.12) x64-mingw32

    kaminari (~> 0.12) x86-mingw32

    kaminari (>= 0) ruby

    kaminari (>= 0) x64-mingw32

    kaminari (>= 0) x86-mingw32

@dblock
Copy link
Contributor

dblock commented Nov 6, 2015

@NekroMancer gem 'kaminari', github: 'amatsuda/kaminari' gives you that? That's something on your side ...

@jakoss
Copy link
Author

jakoss commented Nov 6, 2015

Well, i have no idea what.. It's simple setup on mac

@yuki24
Copy link
Member

yuki24 commented Jan 2, 2016

I'm not sure if this is a kaminari issue. I'll close this issue unless someone can provide a minimal example that can replicate the issue. Thanks!

@yuki24 yuki24 closed this as completed Jan 2, 2016
@ashokap
Copy link

ashokap commented Jan 19, 2017

Hello,

I have been using kaminari with 0.16.3 with mongoid 4.0.2 and ruby ruby 2.1.4p265 with no issues.

Currently I am upgrading my ruby to 2.2.0 and corresnpondingly upgraded mongoid to 5.1.6, kaminari to 1.0.0. Suddenly I am getting errors like
/Users/pana/Desktop/MyRnD-Ruby2.2.0/app/models/user.rb:183:in class:User': undefined method paginates_per' for User:Class (NoMethodError)
I couldn't find any suitable dependency limitation w.r.t mongoid 5.1.6. Any idea why this is happening?

@dblock
Copy link
Contributor

dblock commented Jan 19, 2017

@ashokap The mongoid parts were extracted into https://github.com/kaminari/kaminari-mongoid.

@ashokap
Copy link

ashokap commented Jan 19, 2017

Thanks :) Working fine now. Didn't go through the entire github readme file earlier.

@yuki24
Copy link
Member

yuki24 commented Jan 21, 2017

@dblock Thanks!

@ashokap Like @dblock said, we've split up the gem into small pieces. For more details, please have a look at 5 Major Changes in Kaminari 1.0.0. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants