DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead. #951

Open
mattangriffel opened this Issue Oct 8, 2013 · 3 comments

Projects

None yet

3 participants

@mattangriffel

Is anyone else getting this annoying deprecation warning everywhere in their tests?

DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead. (called from set_accessible_courses at /Users/mgriffel/code/one_month_rails/app/controllers/application_controller.rb:41)

Here's what the relevant parts of my my application_controller look like:

before_filter :set_accessible_courses

  private

    # Sets courses to be looped over in header
    def set_accessible_courses
      @accessible_courses ||= Course.accessible_by(current_ability)
    end

@mhw
mhw commented Oct 8, 2013

Yes, I get that too. It's caused by the use of Model.scoped in lib/cancan/model_adapters/active_record_adapter.rb in the database_records method, but I'm not sure what the correct fix would be.

@hitendrasingh hitendrasingh added a commit to hitendrasingh/cancan that referenced this issue Oct 25, 2013
@hitendrasingh hitendrasingh Fix #951 7b1bf63
@mattangriffel

@hitendrasingh line 101 still throws a deprecation warning:

@model_class.scoped.merge(override_scope)

Can't figure out how to get around this since @model_class.all returns an Array in < 1.9.3 and an ActiveRecord::Relation in > 2.0.0. The merge method doesn't work on arrays.

@thejchap thejchap added a commit that referenced this issue Feb 8, 2014
@thejchap thejchap Rails 4 fix for #951 2ec49be
@thejchap

Seems to be solved by

@model_class.where(nil).merge(override_scope)

Just opened PR #992

@rweng rweng pushed a commit that referenced this issue Jul 22, 2014
@hitendrasingh hitendrasingh Fix #951 b30b125
@rweng rweng pushed a commit that referenced this issue Jul 22, 2014
@thejchap thejchap Rails 4 fix for #951 11867bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment