I'm using the merit gem for badges/points, and it does nothing in the app. In the console it works, but in the app it doesn't.
in merit.rb:
# Use this hook to configure merit parameters
Merit.setup do |config|
# Check rules on each request or in background
config.checks_on_each_request = true
# Define ORM. Could be :active_record (default) and :mongo_mapper and :mongoid
config.orm = :active_record
#Define :user_model_name. This model will be used to grand badge if no :to option is given. Default is "User".
config.user_model_name = "User"
# Define :current_user_method. Similar to previous option. It will be used to retrieve :user_model_name object if no :to option is given. Default is "current_#{user_model_name.downcase}".
config.current_user_method = "current_user"
end
# Create application badges (uses https://github.com/norman/ambry)
Badge.create!({
:id => 1,
:name => 'just-registered'
})
Badge.create!({
:id => 2,
:name => 'voter',
})
Badge.create!({
:id => 3,
:name => 'liker-on-steroids'
})
In point_rules.rb:
module Merit
class PointRules
include Merit::PointRulesMethods
def initialize
# score 10, :on => 'users#update' do
# user.name.present?
# end
#
# score 15, :on => 'reviews#create', :to => [:reviewer, :reviewed]
#
# score 20, :on => [
# 'comments#create',
# 'photos#create'
# ]
score 10, :on => 'users#update' do |user|
user.nickname.present?
end
score 20, :on => 'pictures#create', :to => :user
score 5, :on => 'pictures#vote_up', :to => :user do |picture|
picture.vote_up
end
score 5, :on => 'pictures#vote_against', :to => user do |picture|
picture.vote_against
end
end
end
end
Let's take the 20 points on pictures#create:
def create
@picture = Picture.new(params[:picture])
@picture.user_id = current_user.id
@picture.fame = false
if @picture.save
redirect_to root_path, notice: "Picture saved."
else
redirect_to root_path, error: "Could not save picture."
end
end
routes:
resources :pictures do
member do
post :vote_up
post :vote_against
post :unvote
end
end
but it's not just this. Nothing works, it literally doesn't respond - whatever I do, it gives the user no points or badges.
I am using OmniAuth (facebook) to register the users
Look at this, i think that can give you a way!
good luck!