ruby on rails - Scope conditionals for count? -


how can scope work multiple .count?

scope :level_5, -> { (self.accomplished.key.count > 4) && (self.accomplished.adventure.count > 2) && (self.accomplished.health.count > 2) && (self.accomplished.work.count > 2) } 

i've tried:

scope :level_5, -> { self.accomplished.key.count > 4, self.accomplished.adventure.count > 2, self.accomplished.health.count > 2), (self.accomplished.work.count > 2) } 

or

scope :level_5, -> { accomplished.where(key.count > 4, adventure.count > 2, health.count > 2, work.count > 2) } 

or

scope :level_5, -> { "user.accomplished.key.count > 4" && "user.accomplished.adventure.count > 2" && "user.accomplished.health.count > 2" && "user.accomplished.work.count > 2" } 

it used conditionals if :level_5 trigger x.


Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

python - Getting next two indexes regardless of current index -

ruby - Prevent Custom Validation Error on Association -