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

wrong number of arguments (3 for 2) #26

Open
wazery opened this issue Jul 30, 2014 · 3 comments
Open

wrong number of arguments (3 for 2) #26

wazery opened this issue Jul 30, 2014 · 3 comments

Comments

@wazery
Copy link
Owner

wazery commented Jul 30, 2014

Issue by gabrieltong
Thursday Jan 09, 2014 at 07:17 GMT
Originally opened as muratguzel#59


when i use version 1.0.8 , everything is ok .
after upgrade to 1.0.9 , I got this messa
screen shot 2014-01-09 at 3 13 50
ge .

@wazery
Copy link
Owner Author

wazery commented Jul 30, 2014

Comment by SanderMander
Saturday Feb 08, 2014 at 06:19 GMT


Same problem with rails 3.2
I have to rollback to 1.0.7

@wazery
Copy link
Owner Author

wazery commented Jul 30, 2014

Comment by temkin
Monday Apr 07, 2014 at 17:43 GMT


same problem on rails 3.2.14 with version 1.0.9, rolling back to 1.0.7 solve my issue

@stephendrobinson
Copy link

stephendrobinson commented Sep 27, 2016

Latest gem only works with Rails 4. If you have an older project you want to retro fit, I've created a patch that should work. Just copy and paste the following into a file e.g. ratyrate_patch.rb and put it in your config/initialzers directory. You can follow the standard installation from there and it should work.

module Ratyrate
  extend ActiveSupport::Concern

  def update_current_rate(stars, user, dimension)
    current_rate = rates(dimension).where(rater_id: user.id).first
    current_rate.stars = stars
    current_rate.save!(validate: false)

    if rates(dimension).count > 1
      update_rate_average(stars, dimension)
    else # Set the avarage to the exact number of stars
      a = average(dimension)
      a.avg = stars
      a.save!(validate: false)
    end
  end
end

module Ratyrate
  module ClassMethods

    def ratyrate_rateable(*dimensions)
      has_many :rates_without_dimension, :conditions => { :dimension => nil }, as: :rateable, class_name: 'Rate', dependent: :destroy
      has_many :raters_without_dimension, through: :rates_without_dimension, source: :rater

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

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

        has_many "#{dimension}_raters".to_sym, through: :"#{dimension}_rates", source: :rater

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

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