Skip to content

Commit

Permalink
Fix deprecated Relation#all in Rails 4, use Relation#to_a instead
Browse files Browse the repository at this point in the history
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 followers at .../socialization/lib/socialization/stores/active_record/follow.rb:69)
  • Loading branch information
thmsobrmlr committed Jul 26, 2013
1 parent fafd54e commit 2e1fc43
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/socialization/stores/active_record/follow.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def followers_relation(followable, klass, opts = {})
def followers(followable, klass, opts = {}) def followers(followable, klass, opts = {})
rel = followers_relation(followable, klass, opts) rel = followers_relation(followable, klass, opts)
if rel.is_a?(ActiveRecord::Relation) if rel.is_a?(ActiveRecord::Relation)
rel.all rel.to_a
else else
rel rel
end end
Expand All @@ -92,7 +92,7 @@ def followables_relation(follower, klass, opts = {})
def followables(follower, klass, opts = {}) def followables(follower, klass, opts = {})
rel = followables_relation(follower, klass, opts) rel = followables_relation(follower, klass, opts)
if rel.is_a?(ActiveRecord::Relation) if rel.is_a?(ActiveRecord::Relation)
rel.all rel.to_a
else else
rel rel
end end
Expand Down
4 changes: 2 additions & 2 deletions lib/socialization/stores/active_record/like.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def likers_relation(likeable, klass, opts = {})
def likers(likeable, klass, opts = {}) def likers(likeable, klass, opts = {})
rel = likers_relation(likeable, klass, opts) rel = likers_relation(likeable, klass, opts)
if rel.is_a?(ActiveRecord::Relation) if rel.is_a?(ActiveRecord::Relation)
rel.all rel.to_a
else else
rel rel
end end
Expand All @@ -92,7 +92,7 @@ def likeables_relation(liker, klass, opts = {})
def likeables(liker, klass, opts = {}) def likeables(liker, klass, opts = {})
rel = likeables_relation(liker, klass, opts) rel = likeables_relation(liker, klass, opts)
if rel.is_a?(ActiveRecord::Relation) if rel.is_a?(ActiveRecord::Relation)
rel.all rel.to_a
else else
rel rel
end end
Expand Down
4 changes: 2 additions & 2 deletions lib/socialization/stores/active_record/mention.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def mentioners_relation(mentionable, klass, opts = {})
def mentioners(mentionable, klass, opts = {}) def mentioners(mentionable, klass, opts = {})
rel = mentioners_relation(mentionable, klass, opts) rel = mentioners_relation(mentionable, klass, opts)
if rel.is_a?(ActiveRecord::Relation) if rel.is_a?(ActiveRecord::Relation)
rel.all rel.to_a
else else
rel rel
end end
Expand All @@ -92,7 +92,7 @@ def mentionables_relation(mentioner, klass, opts = {})
def mentionables(mentioner, klass, opts = {}) def mentionables(mentioner, klass, opts = {})
rel = mentionables_relation(mentioner, klass, opts) rel = mentionables_relation(mentioner, klass, opts)
if rel.is_a?(ActiveRecord::Relation) if rel.is_a?(ActiveRecord::Relation)
rel.all rel.to_a
else else
rel rel
end end
Expand Down
4 changes: 2 additions & 2 deletions lib/socialization/stores/redis/base.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def actors(victim, klass, options = {})
result result
end end
else else
actors_relation(victim, klass, options).all actors_relation(victim, klass, options).to_a
end end
end end


Expand All @@ -32,7 +32,7 @@ def victims(actor, klass, options = {})
result result
end end
else else
victims_relation(actor, klass, options).all victims_relation(actor, klass, options).to_a
end end
end end


Expand Down

0 comments on commit 2e1fc43

Please sign in to comment.