Deprecation warning when running in Rails master #484

Closed
nmk opened this Issue Mar 2, 2013 · 8 comments

Comments

Projects
None yet
4 participants

nmk commented Mar 2, 2013

When using draper master in a Rails app running rails master, I see the following deprecation warning:

DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead. (called from decorate at /Users/nmk/.rvm/gems/ruby-2.0.0-p0@ausgaben/bundler/gems/draper-7d632987578c/lib/draper/decoratable.rb:56)

When I run the draper test suite with RAILS_VERSION=master I see no such warning.

This is for current master - 7d63298.

Any idea what might be the issue?

Owner

steveklabnik commented Mar 2, 2013

Seems bad. It is true that scoped is deprecated...

Contributor

haines commented Mar 2, 2013

It's used here, the tests stub scoped which is why the warning does not appear.

Given that scoped is deprecated, but all will not return a query in Rails 3.x, how should we approach this? We could either add a version check (ugh) or just silence the deprecation warning.

nmk commented Mar 2, 2013

Is there a way to check if all returns a query or an array other than relying on a version number? This would be the cleanest option if it is available.

Owner

steveklabnik commented Mar 2, 2013

Not without calling it.

I think we have to add a version check.

Contributor

tovodeverett commented Mar 2, 2013

While we're discussing this, I've been meaning to ask about my final comment on #412 (comment) again. Note that I suspect we could avoid the version check and effectively hide the issue (except for the corner case where someone does ModelClass.decorate) by using the suggested approach. It appears that current_scope is nodoc, but is not marked private or protected.

Contributor

haines commented Mar 3, 2013

@tovodeverett I'm not keen on changing it to use current_scope directly.

  1. Relying on undocumented ActiveRecord internals seems fragile to me
  2. Mongoid doesn't support it
  3. ActiveRecord itself almost never uses it, instead preferring all

@haines haines closed this in 47ee29c Mar 3, 2013

nmk commented Mar 3, 2013

Three cheers for @haines! Thanks a lot for fixing this!

Contributor

haines commented Mar 3, 2013

@nmk no problem! Thanks for reporting :)

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