I have the following named_scope:
named_scope :commentors, lambda { |*args|
{ :select => 'users.*, count(*) as total_comments',
:joins => :comments,
:conditions => { :comments => { :public_comment => 1, :aasm_state => 'posted', :chalkboard_user_id => nil} },
:group => 'users.id',
:having => ['count(*) > ?', args.first || 0],
:order => 'count(*) desc' }
}
I need to refactor the condition to the following:
["(public_comment = ? and box IS NOT NULL and can IS NOT NULL and aasm_state != ?", true, 'removed')]
I’m not having much luck with the syntax to change the condition. Can someone be of kind assistance?
It looks like you just need to give the table name to the fields. I am not sure which table
boxandcanbelong to but this should give you an idea:You also had an open parenthesis at the beginning which I removed.