ruby-on-railsruby-on-rails-3deviseruby-on-rails-3.1

overriding devise after_sign_up_path_for not working


In routes i have the root-path pointing "home#index" but when i try to override that with after_sign_up_path_for keeps redirecting me to the root path when I sign in or sign up. I have tried to put it in both in devise subclassed controller and application_controller, but it didn't work. What do I need to do here?

Application controller

class ApplicationController < ActionController::Base
  protect_from_forgery

  def after_sign_up_path_for(resource)
    show_cities_path(resource)
  end
end

registration controller

class RegistrationsController < ApplicationController
  def after_sign_up_path_for(resource)
    show_cities_path(resource)
  end
end

routes

root :to => "home#index"

Solution

  • Have you checked your show_cities_path exists, by executing rake routes? Might be worth having a look at https://github.com/plataformatec/devise/wiki/How-To:-Change-the-redirect-path-after-destroying-a-session-i.e.-signing-out