I have been trying to find where Devise makes the decision to allow a user to be authorized.
I'm pretty sure (but not certain) this is where Devise ,creates authenticate_user!, user_signed_in?, current_user, and user_session . ~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/devise-4.3.0/lib/devise/controllers/helpers.rb def self.define_helpers(mapping) #:nodoc: mapping = mapping.name class_eval <<-METHODS, __FILE__, __LINE__ + 1 def authenticate_#{mapping}!(opts={}) opts[:scope] = :#{mapping} warden.authenticate!(opts) if !devise_controller? || opts.delete (:force) end def #{mapping}_signed_in? !!current_#{mapping} end def current_#{mapping} @current_#{mapping} ||= warden.authenticate(scope: :#{mapping}) end def #{mapping}_session current_#{mapping} && warden.session(:#{mapping}) end METHODS ActiveSupport.on_load(:action_controller) do if respond_to?(:helper_method) helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session" end end end I use byebug to try to debug things. Assuming def authenticate_#{mapping}!(opts={}) opts[:scope] = :#{mapping} warden.authenticate!(opts) if !devise_controller? || opts.delete (:force) end starts on line 114, I have tried b /home/my-project/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/devise-4.3.0/lib/devise/controllers/helpers.rb :115 byebug then, quite reasonably, complains "*** Line 115 is not a valid breakpoint in file /home/ ... /helpers.rb "module ClassMethods" can be found at line 15 in /home/my-project/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/devise-4.3.0/lib/devise/controllers/helpers.rb So, I tried (byebug) b ClassMethods#authenticate_user! Successfully created breakpoint with id 3 But that does not seem to trip a breakpoint. Interestingly, byebug seems to accept the following (byebug) b ClassMethods#current_user1 Successfully created breakpoint with id 6 even though ClassMethods#current_user1 doesn't exist. So, how to I set a breakpoint and spelunk where Devise does its user authorization? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cb5d14b5-6f07-4d25-99bc-6327747f324d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.