1
votes

I'm trying to sign in and redirect a user to home_path if certain criteria are met, otherwise they are unapproved and redirected to another page. When I sign in the user through the controller, they are redirected to users#show though (users/:id).

How can I sign them in, and get it to redirect to home_path which is 'profile/home' from the registrations controller?

registrations controller:

def after_inactive_sign_up_path_for(resource)
    if resource.location === "New York, NY, United States"
      if (really long query)
        puts "accepted!"
        resource.approved = true 
        resource.save!
        sign_in(resource)
        home_path
      else
        puts "Not accepted"
        '/profile/waitlist'
      end
    else
      puts "City is not New York!"
      '/profile/waitlist'
    end
end

application controller

def after_sign_in_path_for(resource)
   home_path
end

Thank you in advance

1

1 Answers

0
votes

You need to make sure you are using the sign_in_and_redirect_method otherwise the url helpers won't get called.

http://www.rubydoc.info/github/plataformatec/devise/Devise%2FControllers%2FHelpers%3Asign_in_and_redirect