WebappにOmniAuth FaceBookのログインに問題があります。 教えてください。このエラーを修正するにはどうすればよいですか?コードを確認してください。ブラウザでNoMethodError Omniauth FacebookのRailsプロジェクト
エラー:文字列
User.rb:
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
x = auth.info.name.to_a
user.name = x[0]
user.surname = x[1]
user.login = auth.info.uid
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
end
end
Omniauth_callback_controller.rb:
"名姓" の未定義のメソッド `to_a」
def facebook if request.env["omniauth.auth"].info.email.blank? redirect_to "https://stackoverflow.com/users/auth/facebook?auth_type=rerequest&scope=email" end @user = User.from_omniauth(request.env["omniauth.auth"]) 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"] if(@user.surname.nil?) redirect_to new_profile_path else redirect_to my_profile_path end end end
devise.rb:
config.omniauth :facebook, '*********', '*********', {:client_options => {:ssl => {:verify => false}}}
Facebookの認証を個別 'auth.info.first_name'と' auth.info.last_name'を提供することができ、ユーザーはそれらをこのようにアクセスするために、二つ以上の名前を持っている場合には、それはより信頼性が高いでしょう。この他のSO [質問](http://stackoverflow.com/questions/33090322/get-first-name-and-last-name-fields-from-facebook-omniauth)を参照してください。 –