如何通过facebook redirect_uri user_omniauth_authorize_path?

时间:2012-06-09 21:44:16

标签: ruby-on-rails-3 devise omniauth

在我的Rails控制器中,我有类似的东西:

 def authenticate_user!
    if not current_user
      # TODO: after login user should go back to the place she tried to get, not ref url
      redirect_to user_omniauth_authorize_path(:facebook, :redirect_uri => 'http://localhost:3000/some-page-where-user-redirected-after-login')
    end
  end

如何在user_omniauth_authorize_path中传递正确的facebook redirect_uri?

我试过“:redirect_uri =>”但它不起作用。

我需要在登录后将用户重定向到添加评论表单。登录仅通过Facebook Omniauth Devise完成。

1 个答案:

答案 0 :(得分:1)

如果您当前以这样的方式签署用户:

  sign_in_and_redirect @user, :event => :authentication

然后你可以改为:

  sign_in @user, :event => :authentication
  @after_sign_in_url = 'url'
  render 'page to render'