我有以下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' }
}
我需要将条件重构为以下内容:
["(public_comment = ? and box IS NOT NULL and can IS NOT NULL and aasm_state != ?", true, 'removed')]
我没有太多运气改变条件的语法。有人可以得到善意的帮助吗?
答案 0 :(得分:0)
看起来您只需要将表名称赋予字段即可。我不确定哪个表box
和can
属于哪个,但这应该会给你一个想法:
["comments.public_comment = ? and box IS NOT NULL and can IS NOT NULL and comments.aasm_state != ?", true, 'removed')]
你在开头我也有一个左括号。