开发者

Devise sign in redirects to last visited page - but how to make exceptions to that?

I have a problem with my devise redirects. What I got working is that when people sign in to my app, they get redirected back to the same page they were on (the first method below). However, I would like to 2 exceptions to this rule, which I can't get to work!

1) When people sign up, I want them to redirect to the user_root_path.

2) After a user updates their 开发者_如何学Pythonaccount I want them to redirect back to the edit page. Right now it submits to the homepage... I also want to specify a :notice here, but that also doesn't work!

Can anyone help me as to what I'm doing wrong?

in application_controller.rb:

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

in routes.rb:

match 'private' => 'private#index', :as => 'user_root'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜