sign_in_and_redirect如何设计工作?
if @user.persisted? sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format? else session["devise.facebook_data"] = request.env["omniauth.auth"] redirect_to new_user_registration_url end
这种方法存在于facebook omniauth callbacks controller
。 我面临的问题是我没有从facebook获取用户的电话号码,因此@user
不是有效的对象(我有validation
)。 所以,我想将用户重定向到另一个我可以询问电话号码的页面。
如何修改sign_in_and_redirect @user以将我重定向到该页面而不是根url。
Sign_in_and_redirect方法使用after_sign_in_path_for方法确定登录后用户重定向的位置 。
您可以轻松自定义after_sign_in_path_for方法以检查手机是否存在,并调用超级或重定向到用户可以输入其电话号码的页面。
- 使用facebook图表,fb_graph或Koala ruby gem比facebooker2好吗?
- 设计omniauth-facebook redirect_uriurl必须绝对
- 修复Rails oauth facebook x-frame-options sameorigin错误
- 使用link_to Rails设置会话变量
- Devise + Omniauth:未定义的方法`user_omniauth_authorize_path’
- 在Rails中实现通知
- 获取命令行(桌面)应用程序的Facebook身份validation令牌
- 通过facebook,gmail,twitter等在rails应用中找到朋友
- 设计 – 无法在rails视图中显示登录或注销