我已经设计并且可以设置,我在注册后无法将用户重定向到某个页面。
class RegistrationsController < Devise::RegistrationsController
def after_sign_up_path_for(resource)
"http://google.com"
end
end
然后在我的路线中:
authenticated :user do
root :to => "dashboard#show"
end
现在,当我注册用户时,它只会被定向到仪表板#show。我试图让它去google.com,但它并没有。难道我做错了什么?或者在使用CanCan注册后还有另一种方法可以重定向用户吗?
由于
答案 0 :(得分:0)
您可以查看下面给出的链接。
Rails 3 and Devise: Redirecting to page following signup (confirmable)
答案 1 :(得分:0)
答案 2 :(得分:0)
您添加到application_controller.rb
def after_sign_up_path_for(resource)
"http://google.com"
end
或者您可以在路线上使用某些外部链接,如
# in `config/routes.rb` :
match "/google" => redirect("http://google.com"), :as => :google
# in `registrations_controller.rb` :
def after_sign_up_path_for(resource)
google_path
end
如果您使用的是Devise的确认(用户注册后未激活),您可以使用after_inactive_sign_up_path_for
方法。
# controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
def after_inactive_sign_up_path_for(resource)
"http://google.com"
end
end