Devise stored_location_for (resource) returns nil

I read some troubleshooting messages stored_location_forhere, but can't figure out how to figure this out, and am not sure how to troubleshoot.

I tried to delete my custom one after_sign_in_path_for, but that didn't work either. My location is never saved, although, as I understand it, after each session / page refresh, it must store the location. Do I need to do this as a filter manually?

def after_sign_in_path_for(resource)
    stored_location_for(resource) ||
      if resource.is_a?(Account)
        add_quote_to_account(resource)
        if resource.applications.any?
          edit_application_path(resource.applications(true).last)
        else
          root_path
        end
      else
        super
      end
  end
+3
source share
1 answer

, , _ . Devise : store_location_for stored_location_for https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/store_location.rb

, "",

  • store_location_for (: user, my_desired_path) URL- "my_desired_path" "user_return_to". - session [ "user_return_to" ] = my_desired_path. , . "", , -

    def login
        my_desired_path = url_for(controller: 'bookings', action: 'checkout')
        store_location_for(:user, my_desired_path)
    end
    
  • stored_location_for (: user) my_desired_path . , stored_location_for (: user) "my_desired_path".

  • , stored_location_for after_sign_in_path_for (: user), "my_desired_path".

-

stored_location_for (: user) session [: user_return_to], , . stored_location_for (: user) my_desired_path. , , . , , , "my_desired_path".

. , "\ X" A "\ Y" B. :

  • A - store_location_for (: , "\ X" ) .
  • , .
  • B , "\ Y", "\ X" .

. , AJAX .

+6

All Articles