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 - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -