DEPRECATION WARNING: Relation#all is deprecated.
danielgatis opened this issue · comments
Daniel Gatis commented
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)
Jason Earl commented
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
Dimitrij Denissenko commented
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