Scoping two models on approved

Posted by Shaun Frost Duke Jackson on Stack Overflow See other posts from Stack Overflow or by Shaun Frost Duke Jackson
Published on 2013-10-23T11:46:56Z Indexed on 2013/10/23 15:54 UTC
Read the original article Hit count: 166

Filed under:
|

I have three models (Book,Snippet,User) and I'd like to create a scope for where(:approved => true)

I'm doing this so I can use the merit gem to define ranking based on count of approved.

I'm thinking that writing this as a scope might be to complex but I don't know as I've just started leaning scopes.

I've currently got this in my Book & Snippet Model:

scope :approved, -> { where(approved: true) }

I've playing around with this in my user model but I don't think it's correct:

scope :approved, joins(:books && :snippets)

Could anyone help start me off or give me some suggestions on what to read?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about scope