0

我正在尝试关注此链接以帮助将linkedin gem 与omniauthable 设计Rails 平台集成。

http://renderedtext.com/blog/2011/08/17/how-to-use-linkedin-gem-with-omniauth/

两个快速的问题!

  1. 底部的“LinkedinFactory 类”文件将位于应用程序中的什么位置,它会被称为什么?我在上面的链接中没有看到目录/文件名。

  2. 当我尝试通过linkedin登录时,我的应用程序当前失败:

    OmniauthCallbacksController#linkedin 中的 NoMethodError

    nil:NilClass 的未定义方法“create_linkedin_connection”

我将在哪里以及如何定义“create_linkedin_connection”方法?它在 omniauth_callbacks.rb 控制器的第 3 行中调用:

def linkedin
    omniauth_hash = env["omniauth.auth"]
    current_user.create_linkedin_connection(
      :token  => omniauth_hash["extra"]["access_token"].token,
      :secret => omniauth_hash["extra"]["access_token"].secret,
      :uid    => omniauth_hash["uid"]
    )
    redirect_to root_path, :notice => "You've successfully connected your LinkedIn account."
  end

谢谢!

4

1 回答 1

0

1) 用户定义的类通常应该放在你的lib 目录中

2) 您在 current_user 上调用“create_linkedin_connection”方法,在这种情况下,该方法需要在用户控制器中。更改后,您需要确保在您的 routes.rb 文件中指定路由。路线应该这样定义

match '/auth/callback', to: 'users#create_linkedin_connection'
于 2012-07-30T23:24:28.147 回答