1
내 사이트에 OmniAuth Facebook을 통합하려고합니다. 나는 그것을 작동 시켰지만 몇 가지 사용자 모델을 추가하고 싶었다. 여기 내 user.rb 내가 페이스 북으로 인증되면OmniAuth + Facebook : 문자열을 정수로 변환 할 수 없습니다.
class User < ActiveRecord::Base
def self.create_with_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
user.email = auth["info"]["email"]
user.name = auth["info"]["name"]
user.first_name = auth["info"]["first_name"]
user.last_name = auth["info"]["last_name"]
user.birthday = auth["extra"]["raw_info"]["birthday"]
user.location = auth["info"]["location"]
user.hometown = auth["extra"]["raw_info"]["hometown"]["name"]
user.employer = auth["extra"]["raw_info"]["work"]["employer"]["name"]
user.position = auth["extra"]["raw_info"]["work"]["position"]["name"]
user.gender = auth["extra"]["raw_info"]["gender"]
user.school = auth["extra"]["raw_info"]["education"]["school"]
user.token = auth["credentials"]["token"]
end
end
end
, 나는 다음과 같은 오류 얻을 알 수 있습니다 :
TypeError (can't convert String into Integer):
app/models/user.rb:13:in `[]'
app/models/user.rb:13:in `block in create_with_omniauth'
app/models/user.rb:3:in `create_with_omniauth'
app/controllers/sessions_controller.rb:4:in `create'
내가 user.rb 게시를
sessions_controller.rb에서 4 호선은
입니다user = user.find_by_provider_and_uid (auth [ "provider"], auth [ "uid"]) || User.create_with_omniauth (auth)
안녕하세요, 올바른 것처럼 보입니다. 나는 일과 교육에 관한 라인을 주석 처리했으며 작동한다. 배열을 고려하여 user.rb를 어떻게 편집합니까? – Victor
답변이 수정되었습니다. –