Reputation: 639
I have created a rails application, In my rails application I have two models created using devise gem, Student and Teacher. Now I want to add merit gem for Student to assign them badges and points. I have tried a lot and follow each and every step given on [1]: https://github.com/tute/merit and also search questions given on stackoverflow, but it's not so much helpful.
In my controller, students/registrations_controller.rb
class Students::RegistrationsController < Devise::RegistrationsController
def create
@student = build_resource
super
end
end
In my model i have added has_merit in class Student
In my config/initializer/merit.rb
Merit.setup do |config|
config.checks_on_each_request = true
config.orm = :active_record
config.user_model_name = 'Student'
end
badge_id = 0
[{
id: (badge_id = badge_id+1),
name: 'just-registered'
}, {
id: (badge_id = badge_id+1),
name: 'best-unicorn',
custom_fields: { category: 'fantasy' }
}].each do |attrs|
Merit::Badge.create! attrs
end
My models/merit/badges_rule.rb has the following code line grant_on 'students/registrations#create', badge: 'best-unicorn', model_name: 'Student'
i have created all migrations and database tabels. Everytime on signup my sash_id set to nil. I don't get the sash_id in Student's table.
Upvotes: 1
Views: 260
Reputation: 1032
What if you only write class RegistrationsController < Devise::RegistrationsController
?
And then in your badges_rule.rb grant_on 'registrations#create', badge: 'best-unicorn', to: :user
Upvotes: 1