我在Rails 4應用程序中使用了letsrate gem。我已經添加了寶石到我的lib文件,並改變了它有點爲使其使用Rails 4.現在的工作,我得到一個過時的警告這樣的:運行時用於關聯的rails服務器的棄用警告
DEPRECATION WARNING: The following options in your Performer.has_many :rates_without_dimension declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:76) DEPRECATION WARNING: The following options in your Performer.has_one :rate_average_without_dimension declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:79) DEPRECATION WARNING: The following options in your Performer.has_many :performance_rates declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from block in letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:84) DEPRECATION WARNING: The following options in your Performer.has_one :performance_average declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment' . (called from block in letsrate_rateable at /home/aravind/Documents/dev/gw-c4u/lib/letsrate/lib/letsrate/model.rb:91)
產生這樣的錯誤文件的一部分是這樣的:
module ClassMethods
def letsrate_rater
has_many :ratings_given, :class_name => "Rate", :foreign_key => :rater_id
end
def letsrate_rateable(*dimensions)
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
end
我試圖使:依賴=>:破壞的線的最後部分和不斷變化的條件=> {:尺寸=> dimension.to_s}至 - > {:尺寸=> dimension.to_s}。它只會拋出錯誤。我究竟做錯了什麼?
警告哈希告訴你的行被改變是在'Performer'中,所以也許你的'performer.rb'模型文件。 –
這是它指向letrate_rateable「性能」 的行。我很確定它輪流取代上述的寶石線。 – Aravind