Search code examples
rubyruby-on-rails-3.2sorcery

alias_method chain issue in application controller


I'm using sorcery for login. In my application controller i'm overwriting sorcery logged_in? method by using alias_method chain as follows.

alias_method_chain :logged_in?, sorcery

protected:

  def logged_in?
    sorcery_logged_in? && (current_user.customer? || current_user.activated?)
  end

Finally am ending up with "undefined method sorcery_logged_in?' for classApplicationController'" error

Can anyone help me whats the mistake here.


Solution

  • Given you are using alias_method_chain, I think you'd try:

    alias_method_chain :logged_in?, :sourcery
    

    And then use the methods logged_in_without_sourcery? and logged_in_with_sourcery?.

    Check the docs of Module#alias_method_chain.