Skip to content
Browse files

Use '&' operator to merge relations within scope definition (thanks f…

…or the tip, @rbates)
  • Loading branch information...
1 parent dacf987 commit a34e6581060eb45e3c18c95151cdd069e0c87371 @rwdaigle committed
Showing with 1 addition and 6 deletions.
  1. +1 −6 the-skinny-on-scopes-formerly-named-scope/app/models/user.rb
View
7 the-skinny-on-scopes-formerly-named-scope/app/models/user.rb
@@ -5,11 +5,6 @@ class User < ActiveRecord::Base
validates_presence_of :username
- scope :published, lambda {
- joins(:posts).
- where(Post.published.where_values).
- group("users.id")
- }
-
+ scope :published, lambda { joins(:posts).group("users.id") & Post.published }
scope :commented, joins(:comments).group("users.id")
end

0 comments on commit a34e658

Please sign in to comment.
Something went wrong with that request. Please try again.