I'm trying to write a simple helper method that checks if a user's email address contains a specific domain name. The method is needed in all my controllers and depends on the state of current_user
, so I felt the best place to put it would be in my ApplicationController. Depending on the evaluation of the method on line 3, a second helper method is called. I modeled my setup on this question's answer.
When I insert this code and refresh the page, the binding.pry
should be hit, indicating that the helper method I defined is being evaluated, but this doesn't happen. Instead, :disable_intercom?
evaluates to true without hitting the method below. If I remove the colon, I get an error saying disable_intercom?
is undefined. What am I missing here?
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
skip_after_action :intercom_rails_auto_include if :disable_intercom?
private
def disable_intercom?
binding.pry
if user_signed_in?
current_user.email.split('@').include?('mysite.com') ? true : false
else
false
end
end
end
Thanks!
Aucun commentaire:
Enregistrer un commentaire