Redirect 设计登录重定向到上次访问的页面-但如何对此进行例外?
我的设计重定向有问题。我的工作是,当人们登录到我的应用程序时,他们会被重定向回原来的页面(下面的第一种方法)。然而,我想对这条规则有两个例外,我不能去工作 1) 当人们注册时,我希望他们重定向到用户根路径 2) 用户更新帐户后,我希望他们重定向回编辑页面。现在它提交到主页。。。我还想在这里指定一个:注意,但这也不起作用 有人能帮我弄清楚我做错了什么吗 在应用程序_controller.rb中:Redirect 设计登录重定向到上次访问的页面-但如何对此进行例外?,redirect,path,routes,devise,Redirect,Path,Routes,Devise,我的设计重定向有问题。我的工作是,当人们登录到我的应用程序时,他们会被重定向回原来的页面(下面的第一种方法)。然而,我想对这条规则有两个例外,我不能去工作 1) 当人们注册时,我希望他们重定向到用户根路径 2) 用户更新帐户后,我希望他们重定向回编辑页面。现在它提交到主页。。。我还想在这里指定一个:注意,但这也不起作用 有人能帮我弄清楚我做错了什么吗 在应用程序_controller.rb中: def after_sign_in_path_for(resource_or_scope) cas
def after_sign_in_path_for(resource_or_scope)
case resource_or_scope
when :user, User
store_location = session[:return_to]
clear_stored_location
(store_location.nil?) ? user_root_path : store_location.to_s
else
super
end
end
def after_update_path_for(resource)
# set_flash_message :notice
flash[:notice] = "Account is changed!"
edit_user_registration_path
# :notice => "succesfully updated your account"
end
def after_sign_up_path_for(resource_or_scope)
case resource_or_scope
when :user, User
user_root_path
else
super
end
end
def after_inactive_sign_up_path_for(resource)
user_root_path
end
在routes.rb中:
match 'private' => 'private#index', :as => 'user_root'