2014-07-08 20 views
8

Aşağıdaki dernekler kodu vardır:Bilinmeyen anahtar

has_many :rates_without_dimension, :as => :rateable, :class_name => "Rate", :dependent => :destroy,-> { where(:dimension => nil) } 

:

Unknown key: :conditions. Valid keys are: :class_name, :class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache 

ben içine ilk satırını değiştirmeye çalıştı: Bu bir hata tutarsa ​​

has_many :rates_without_dimension, :as => :rateable, :class_name => "Rate", 
    :dependent => :destroy, :conditions => {:dimension => nil} 
has_many :raters_without_dimension, :through => :rates_without_dimension, 
    :source => :rater 

has_one :rate_average_without_dimension, :as => :cacheable, 
    :class_name => "RatingCache", 
:dependent => :destroy, :conditions => {:dimension => nil} 


dimensions.each do |dimension|   
    has_many "#{dimension}_rates", :dependent => :destroy, 
    :conditions => {:dimension => dimension.to_s}, 
    :class_name => "Rate", 
    :as => :rateable 

    has_many "#{dimension}_raters", :through => "#{dimension}_rates", 
    :source => :rater   

    has_one "#{dimension}_average", :as => :cacheable, :class_name => "RatingCache", 
    :dependent => :destroy, :conditions => {:dimension => dimension.to_s} 
end 

Ama aynı zamanda bir hataya sebep oldu, bana neyin yanlış olduğunu gösterebilir misin? Ben örneklerde de görebileceğiniz gibi

+2

Sorguyu, kaynak kodu harici bir siteye eklemek üzere düzenleyin. [SO yardım] 'dan (http://stackoverflow.com/help/how-to-ask): "Bağlayabileceğiniz sorunun canlı bir örneğini oluşturmak mümkün ise (örneğin, http: // sqlfiddle.com/ veya http://jsbin.com/) o zaman bunu yapın - ama aynı zamanda sorunuzu kendi koduna dahil edin. Herkes harici sitelere erişemez ve bağlantılar zamanla bozulabilir. " – Amadan

+0

Düzenleme ve alıntı için teşekkürler :) –

+0

-> notasyonu kullanarak hata neydi? – JTG

cevap