0

I have a trouble at this situation. I followed this manual, but it don't helped me.

Here's my files:

routes.rb:

devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks', registrations: 'registrations' }

merit.rb:

Merit.setup do |config|
  config.checks_on_each_request = true
end

Merit::Badge.create!(
  id: 1,
  name: 'just-registered',
  description: 'Badge for register'
)

badge_rules.rb

module Merit
  class BadgeRules
    include Merit::BadgeRulesMethods

    def initialize
      grant_on 'registrations#create', badge: 'just-registered', model_name: 'User'
    end
  end
end

registrations_controller.rb

def create
  @user = build_resource
  super
end

And if make sense - when user is registered, to merit_actions table added a new record with target_model = 'registrations', not 'users'

Can someone tell me, what i'm doing wrong ?

TuteC
  • 4,342
  • 30
  • 40

1 Answers1

0

That's expected behavior, merit_actions is internal to the gem and saves controller_path as it's target_model attribute. It is confusing, but it shouldn't affect your application. Is the badge being granted?

TuteC
  • 4,342
  • 30
  • 40
  • Its working if we use `to: :action_user` with the rule defined above ,but what if we are using devise ` confirmable` functionality.It not creating badge in that case – Jaswinder Aug 30 '16 at 06:46
  • With comfirmable, it's maybe another endpoint than `registrations#create` that you should target. I'd need to see the app to provide more help. – TuteC Aug 30 '16 at 13:34