neon
neon

Reputation: 2821

Twitter's activerecord-reputation-system gem + Devise

I am working with Twitter's new activerecord-reputation-system gem, yet it doesn't seem to be registering in my app.

I ran to install (docs have a typo):

gem install activerecord-reputation-system && rails generate reputation_system && rake db:migrate

I've included it in my gemfile and tried pulling directly from github, as well as restarting my local server. The error is the following:

ActionController::RoutingError (undefined method has_reputation' for #<Class:0x007fa7ed783ec0>): app/models/post.rb:18:in' app/models/post.rb:1:in <top (required)>' app/controllers/posts_controller.rb:1:in'

when I try to add votes to posts with this code:

class Post < ActiveRecord::Base
  belongs_to :user
  has_reputation :votes,
    :source => :user,
    :aggregated_by => :sum
end

When I try to add votes to users with the same code I get:

undefined method `has_reputation' for #<Class:0x007fa7efb70388>

app/models/user.rb:17:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
config/routes.rb:4:in `block in <top (required)>'
config/routes.rb:1:in `<top (required)>'

This error occurred while loading the following files:
   /Users/username/appname/config/routes.rb

routes.rb, Line 4:

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }

Any ideas?

Upvotes: 1

Views: 458

Answers (1)

NARKOZ
NARKOZ

Reputation: 27931

You should require reputation_system in your app. You can do this by adding to your Gemfile:

gem 'activerecord-reputation-system', :require => 'reputation_system'

Update: As of version 2.0.0 you don't need to require reputation_system anymore:

gem 'activerecord-reputation-system'

Upvotes: 4

Related Questions