0

我有以下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')]

我对更改条件的语法不太满意。有人可以提供帮助吗?

4

1 回答 1

0

看起来您只需要为字段提供表名。我不确定属于哪个表boxcan但这应该给你一个想法:

["comments.public_comment = ? and box IS NOT NULL and can IS NOT NULL and comments.aasm_state != ?", true, 'removed')]

您在开头还有一个左括号,我将其删除。

于 2010-07-10T00:07:18.177 回答