wazery / ratyrate

:star: A Ruby Gem that wraps the functionality of jQuery Raty library, and provides optional IMDB style rating.
http://ratingmoviestore.herokuapp.com
237 stars 120 forks source link

`has_many': wrong number of arguments (3 for 2) (ArgumentError) #28

Open wazery opened 10 years ago

wazery commented 10 years ago

Issue by shivakumaarmgs Tuesday Mar 04, 2014 at 19:26 GMT Originally opened as https://github.com/muratguzel/letsrate/issues/62


I followed the README and tried implementing this gem. Created all the necessary models, ran the generators and migrated the databases. Added necessary lines in User model and Conference model.

letsrate generator for User model. Here user model is devise generated model

rails g letsrate User

create  app/assets/javascripts/jquery.raty.js
      create  app/assets/images/star-on.png
      create  app/assets/images/star-off.png
      create  app/assets/images/star-half.png
      create  app/assets/javascripts/letsrate.js.erb
      create  app/controllers/rater_controller.rb
      create  app/models/rate.rb
      create  app/models/rating_cache.rb
       route  post '/rate' => 'rater#create', :as => 'rate'
      create  db/migrate/20140304180848_create_rating_caches.rb
      create  db/migrate/20140304180849_create_rates.rb

$ rake db:migrate
==  CreateRatingCaches: migrating =============================================
-- create_table(:rating_caches)
   -> 0.0015s
-- add_index(:rating_caches, [:cacheable_id, :cacheable_type])
   -> 0.0007s
==  CreateRatingCaches: migrated (0.0025s) ====================================

==  CreateRates: migrating ====================================================
-- create_table(:rates)
   -> 0.0026s
-- add_index(:rates, :rater_id)
   -> 0.0012s
-- add_index(:rates, [:rateable_id, :rateable_type])
   -> 0.0012s
==  CreateRates: migrated (0.0054s) ===========================================

#app/model/user.rb
class User < ActiveRecord::Base
  include PublicActivity::Common
  recommends :conferences
  letsrate_rater
.
.
end

#app/model/conference.rb
class Conference < ActiveRecord::Base
  searchkick autocomplete: ['subject']
  include PublicActivity::Common
  letsrate_rateable "quality"
.
.
end

So have prepared my app as per the instructions given in the README. now when I run the rails server I get the following error.

/home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.9/lib/active_record/associations.rb:1197:in `has_many': wrong number of arguments (3 for 2) (ArgumentError)
    from /home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/letsrate-1.0.9/lib/letsrate/model.rb:87:in `letsrate_rateable'
    from /home/shivakumaarmgs/Rails/talkingslate/app/models/conference.rb:5:in `<class:Conference>'
    from /home/shivakumaarmgs/Rails/talkingslate/app/models/conference.rb:1:in `<top (required)>'
    from /home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:469:in `load'
    from /home/shivakumaarmgs/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:469:in `block in load_file'
and it goes on

What am I doing wrong

ruby version 1.9.3
rails version 3.2.9
wazery commented 10 years ago

Comment by shivakumaarmgs Tuesday Mar 04, 2014 at 19:54 GMT


Sorry that I closed and reopened. It was an accident. The problem still exists.

wazery commented 10 years ago

Comment by shaimo Sunday Mar 23, 2014 at 13:45 GMT


I have the same issue. Seems like some incompatibility issue with rails 3...?

wazery commented 10 years ago

Comment by settheline Sunday Mar 23, 2014 at 19:08 GMT


I also have this issue with Rails 3.2....

wazery commented 10 years ago

Comment by shivakumaarmgs Monday Mar 24, 2014 at 06:43 GMT


I got it working by using a lower version of the gem ie, letsrate-1.0.8. I haven't tried the new version again yet.

wazery commented 10 years ago

Comment by rasool-sb Tuesday Jul 15, 2014 at 18:14 GMT


Yep.. previous version works fine.

coalwater commented 10 years ago

I have the same issue after upgrading to 1.0.9, but i don't want to use 1.0.8 because it has a security vulnerability in the controller because it's using eval, an issue that is supposedly fixed in 1.0.9

EDIT: I managed to patch the issue by copying from 1.0.9's controller, if anyone's interested

https://gist.github.com/coalwater/2bbd036e9e990187a742#file-rater_controller-patch