title: Devise after_sign_in_path_for not working; being ignored when model has validations on: :update
body: <p>My method is executing, but Devise is not using the return value at all. On the sign in page, it just reloads the page with a 'Signed in successfully' notice. It doesn't redirect to the value returned from the method.</p>
  <h3>Log</h3>
  <pre><code>Started POST &quot;/users/sign_in&quot; for 127.0.0.1 at 2018-03-05 22:19:50 -0500
  Processing by Users::SessionsController#create as HTML
    Parameters: {&quot;utf8&quot;=&gt;&quot;√&quot;, &quot;authenticity_token&quot;=&gt;&quot;tQd5a43StP85oyyCpEmFU8cAkFXdJL2OLpuAK1+sqQC6/rIqcd+fB2iE4RT0RoPKPCqreNBYlv2bxjl9gZFrWg==&quot;, &quot;user&quot;=&gt;{&quot;email&quot;=&gt;&quot;test11@example.com&quot;, &quot;password&quot;=&gt;&quot;[FILTERED]&quot;, &quot;remember_me&quot;=&gt;&quot;0&quot;}, &quot;commit&quot;=&gt;&quot;Log in&quot;}
    User Load (2.0ms)  SELECT  &quot;users&quot;.* FROM &quot;users&quot; WHERE &quot;users&quot;.&quot;email&quot; = $1 ORDER BY &quot;users&quot;.&quot;id&quot; ASC LIMIT $2  [[&quot;email&quot;, &quot;test11@example.com&quot;], [&quot;LIMIT&quot;, 1]]
     (5.0ms)  BEGIN
    User Exists (3.0ms)  SELECT  1 AS one FROM &quot;users&quot; WHERE &quot;users&quot;.&quot;email&quot; = $1 AND (&quot;users&quot;.&quot;id&quot; != $2) LIMIT $3  [[&quot;email&quot;, &quot;test11@example.com&quot;], [&quot;id&quot;, 23], [&quot;LIMIT&quot;, 1]]
    Sector Load (0.0ms)  SELECT &quot;sectors&quot;.* FROM &quot;sectors&quot; INNER JOIN &quot;sectors_users&quot; ON &quot;sectors&quot;.&quot;id&quot; = &quot;sectors_users&quot;.&quot;sector_id&quot; WHERE &quot;sectors_users&quot;.&quot;user_id&quot; = $1  [[&quot;user_id&quot;, 23]]
    Region Load (0.0ms)  SELECT &quot;regions&quot;.* FROM &quot;regions&quot; INNER JOIN &quot;regions_users&quot; ON &quot;regions&quot;.&quot;id&quot; = &quot;regions_users&quot;.&quot;region_id&quot; WHERE &quot;regions_users&quot;.&quot;user_id&quot; = $1  [[&quot;user_id&quot;, 23]]
    Criterium Load (0.0ms)  SELECT &quot;criteria&quot;.* FROM &quot;criteria&quot; INNER JOIN &quot;criteria_users&quot; ON &quot;criteria&quot;.&quot;id&quot; = &quot;criteria_users&quot;.&quot;criterium_id&quot; WHERE &quot;criteria_users&quot;.&quot;user_id&quot; = $1  [[&quot;user_id&quot;, 23]]
    AssetType Load (0.0ms)  SELECT &quot;asset_types&quot;.* FROM &quot;asset_types&quot; INNER JOIN &quot;asset_types_users&quot; ON &quot;asset_types&quot;.&quot;id&quot; = &quot;asset_types_users&quot;.&quot;asset_type_id&quot; WHERE &quot;asset_types_users&quot;.&quot;user_id&quot; = $1  [[&quot;user_id&quot;, 23]]
    Company Load (1.0ms)  SELECT  &quot;companies&quot;.* FROM &quot;companies&quot; WHERE &quot;companies&quot;.&quot;id&quot; = $1 LIMIT $2  [[&quot;id&quot;, 42], [&quot;LIMIT&quot;, 1]]
     (5.0ms)  ROLLBACK
  ############### /users/23/edit
    Rendering users/sessions/new.haml within layouts/application
    Rendered users/shared/_links.html.erb (3.0ms)
    Rendered users/sessions/new.haml within layouts/application (251.2ms)
    Rendered layouts/_footer.haml (15.0ms)
  Completed 200 OK in 6554ms (Views: 3364.9ms | ActiveRecord: 86.1ms)
  </code></pre>
  <p>Notice it is rendering <code>users/sessions/new.haml</code> instead of the edit page?</p>
  <h3>Code</h3>
  <pre><code>class ApplicationController &lt; ActionController::Base
  ...
    def after_sign_in_path_for(resource)
      logger.debug '############### ' + edit_user_path(resource) if resource.is_a?(User) &amp;&amp; resource.signature.blank?
      return edit_user_path resource if resource.is_a?(User) &amp;&amp; resource.signature.blank?
      stored_location_for(resource) ||
        if resource.is_a?(User)
          dashboard_path
        elsif resource.is_a?(Facilitator) &amp;&amp; resource.name.nil?
          edit_facilitator_path resource
        elsif resource.is_a?(Facilitator)
          facilitator_path resource
        else
          super
        end
    end
  </code></pre>
  <p>I completely commented out the method and it still reloaded the login page.</p>
  <pre><code>Started POST &quot;/users/sign_in&quot; for 127.0.0.1 at 2018-03-05 22:25:21 -0500
  ...
    Rendering users/sessions/new.haml within layouts/application
  </code></pre>
  <p>Devise 4.4.0</p>
  <p>Documentation:</p>
  <p><a href="https://github.com/plataformatec/devise/wiki/How-To%3A-Redirect-to-a-specific-page-on-successful-sign-in-and-sign-out" rel="noreferrer">https://github.com/plataformatec/devise/wiki/How-To%3A-Redirect-to-a-specific-page-on-successful-sign-in-and-sign-out</a></p>
  <p><a href="http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Controllers/Helpers:after_sign_in_path_for" rel="noreferrer">http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Controllers/Helpers:after_sign_in_path_for</a></p>
  <hr />
  <p>I added</p>
  <pre><code>  def after_sign_in_path_for(resource)
      logger.debug '############# ' + resource.errors.full_messages.join(', ')
  </code></pre>
  <p>And did discover validation errors like</p>
  <pre><code> ############# Title can't be blank, Country can't be blank, Signature can't be blank, ...
  </code></pre>
  <p>But it does show the notice</p>
  <pre><code>Signed in successfully.
  </code></pre>
  <p>And I do have a session and can navigate elsewhere. My validations are <code>on: :update</code>.</p>
  <pre><code>  validates :email, :name, :title, :phone, :address1, :city, :state, :zip, :country, :type, :signature, presence: true, on: :update
  </code></pre>
  <p>This should not cause log in behavior errors.</p>
  <hr />
  <p>I commented all validations on the model and it does work, but this is highly unusual! Validations should not affect login behavior. There has to be a workaround.</p>
  <pre><code>Started POST &quot;/users/sign_in&quot; for 127.0.0.1 at 2018-03-05 23:11:43 -0500
    SQL (15.0ms)  UPDATE &quot;users&quot; SET &quot;current_sign_in_at&quot; = $1, &quot;last_sign_in_at&quot; = $2, &quot;current_sign_in_ip&quot; = $3, &quot;sign_in_count&quot; = $4, &quot;updated_at&quot; = $5 WHERE &quot;users&quot;.&quot;id&quot; = $6  [[&quot;current_sign_in_at&quot;, &quot;2018-03-06 04:11:44.225501&quot;], [&quot;last_sign_in_at&quot;, &quot;2017-11-09 01:22:28.245231&quot;], [&quot;current_sign_in_ip&quot;, &quot;127.0.0.1/32&quot;], [&quot;sign_in_count&quot;, 6], [&quot;updated_at&quot;, &quot;2018-03-06 04:11:44.230506&quot;], [&quot;id&quot;, 23]]
  Redirected to http://localhost:3000/users/23/edit
  Completed 302 Found in 2183ms (ActiveRecord: 48.0ms)
  </code></pre>