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

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

Open
shivakumaarmgs opened this issue Mar 4, 2014 · 5 comments
Open

Comments

@shivakumaarmgs
Copy link

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
Copy link
Author

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

@shaimo
Copy link

shaimo commented Mar 23, 2014

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

@fwilkens
Copy link

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

@shivakumaarmgs
Copy link
Author

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
Copy link

Yep.. previous version works fine.

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

4 participants