muratguzel / letsrate

The best way to add rating capabilities to your rails application and your activerecord models.
http://letsrate.herokuapp.com
198 stars 234 forks source link

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

Open shivakumaarmgs opened 10 years ago

shivakumaarmgs commented 10 years ago

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
shivakumaarmgs commented 10 years ago

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

shaimo commented 10 years ago

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

fwilkens commented 10 years ago

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

shivakumaarmgs commented 10 years ago

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.

rasool-sb commented 10 years ago

Yep.. previous version works fine.