Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation warning when running rails console for associations #48

Closed
aravindgd opened this issue Oct 1, 2013 · 2 comments
Closed

Comments

@aravindgd
Copy link

I am using the letsrate gem in Rails 4 application. I have added the gem into my lib file and changed it a bit for making it to work with Rails 4. Now I am getting a deprecated warning like this:

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)

The part of the file which generates such an error is this:

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

I have tried bringing the :dependent=>:destroy to the last part of the line and changing conditions => {:dimension => dimension.to_s} to -> {:dimension => dimension.to_s}. It only throws errors. What am I doing wrong?

@muratguzel
Copy link
Owner

Hi .. For a long time, I have not enough time to mange this gem. But nowadays I'm available. You can check this issue 2-3 days later. Thanks ...

@muratguzel
Copy link
Owner

Fixed and new version 1.0.9 is released. Thanks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants