Search code examples
ruby-on-railsruby-on-rails-4sorcery

Custom user activation methods in sorcery


I am using the sorcery gem in a Rails 4 application. I need to configure two attributes that sorcery says I can configure, however I do not know how to actually configure those values.

The two attributes in question are:

activation_needed_email

and

activation_success_email

How can I customize these method names?


Solution

  • The attributes you want to override are activation_needed_email_method_name and activation_success_email_method_name, as seen here: https://github.com/NoamB/sorcery/blob/master/lib/sorcery/model/submodules/user_activation.rb

    Solution There are a number of ways to accomplish this. Something like this should work:

    In your sorcery.config file:

    Rails.application.config.sorcery.configure do |config|
      config.user_config do |user|
        user.activation_needed_email_method_name = :whatever_your_method_is
        user.activation_success_email_method_name = :whatever_your_method_is
      end
    end
    

    Reference: Here is a good gist with example configurations for many (all?) things that are configurable within sorcery: https://gist.github.com/reqshark/3063261