2010-07-09 56 views
0

我有以下named_scope:幫助重構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

你得到的錯誤是什麼? – 2010-07-09 23:49:05

+0

沒有具體錯誤。只要確保如何去... – keruilin 2010-07-10 00:06:18

回答

0

它看起來像你只需要將表名稱的字段。我不知道哪個表boxcan屬於但這應該給你一個想法:

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

您也有一個開放的括號在我刪除的開始。