activeadmin / inherited_resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DEPRECATION WARNING: Relation#all is deprecated.

danielgatis opened this issue · comments

DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. Post.where(published: true).load). If you want to get an array of records from a relation, you can call #to_a (e.g. Post.where(published: true).to_a).

(called from collection at ... /lib/inherited_resources/base_helpers.rb:26)

Probably not the nicest work around but in base_helpers.rb I amended the collection method to:

def collection
  get_collection_ivar || begin
    chain = end_of_association_chain
    use_scoped = chain.respond_to?(:scoped) && !ActiveRecord.const_defined?(:DeprecatedFinders)
    items = case
      when use_scoped then chain.scoped
      when chain.is_a?(ActiveRecord::Relation) then chain
      else chain.all
    end
    set_collection_ivar items
  end
end

I tried to submit a pull request for rails, but it was rejected: rails/rails#11310. Seems like this needs to be fixed in inherited_resources

Resolved in #298