Skip to content

Subclassed models generate scope override warnings #48

Closed
pdobb opened this Issue Mar 3, 2011 · 7 comments

8 participants

@pdobb
pdobb commented Mar 3, 2011

In Rails 3.0.5, any subclassed model that is loaded, ever, will produce the following warning in the Rails server log:

Creating scope :page. Overwriting existing method <model_name>.page.

I believe a proper fix here would be to have Kaminari make sure that it has not created the page (and others?) scope before doing so. This way, when a subclass initializes it would not recreate/override the scope that was already defined on the parent class. It's not necessary and it produces this warning message (see: https://rails.lighthouseapp.com/projects/8994/tickets/4083-patch-named-scopes-should-be-allowed-to-overwrite-an-existing-method).

If you'd like to see a sample app where this happens I can upload one to github.

Thanks!

@echon
echon commented Apr 1, 2011

I get the same thing, Rails 3.0.5 and Ruby 1.8.7

Creating scope :page. Overwriting existing method Brush.page.
Creating scope :page. Overwriting existing method Pattern.page.
Creating scope :page. Overwriting existing method Photo.page.
Creating scope :page. Overwriting existing method Texture.page.

All of those are sub-classes to Asset. None of which define paginates_per in their models (actually none of my models do).

@amatsuda amatsuda was assigned Apr 21, 2011
@amatsuda
Owner

Thanks for reporting! (and sorry for not responding this long).
Confirmed this issue, but I still wonder whether Kaminari should just check the existing scopes and skip overwriting, or should do overwrite.
Let me think a little bit more...

@thegorgon

Any update on this? It's still an issue. Seems it should realize if it's a subclass...

@diddeb
diddeb commented Dec 10, 2011

Any planned progress on this? Still seeing the exact same problem as pdobb initially described. I am on Rails 3.1.1.

@dsgh
dsgh commented Dec 28, 2011

I had the same problem, but it seems to be fixed as of 0.13.0.

@lucapette

Yes the 0.13 solved this. This one should be definitely closed.

@yuki24
Collaborator
yuki24 commented Jul 3, 2012

I'm closing this issue since this is a duplicate of #57.

@yuki24 yuki24 closed this Jul 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.