모든 Facebook 관련 문제를 처리 할 개체를 만들고 싶습니다. 예를 들어, object.is_access_token_valid라고 말하고 싶습니다. 또는 object.get_user_email 또는 object.authenticate_user. 이 하나의 객체에 패키지하기를 원하는 많은 복잡한 기능이 있으며 객체의 사용자로부터이를 추상화하려고합니다. 자바에서는 이것이 객체가 될 것입니다. 이것이 루비/레일에 무엇이 될까요?레일 모델을 만들고 싶지만 데이터베이스에 저장하고 싶지 않습니다.
나는이 오류가 무엇입니까 : 액티브 :: StatementInvalid을 :
가 여기 내 특정 상황의
class FacebookSession < ActiveRecord::Base
#include OauthHelper
attr_accessor :fb_token, :fb_client, :fb_user_id, :fb_email
def initialize
@fb_client = client # makes new oauth client
@fb_token = OAuth2::AccessToken.new client, fb_token
end
def get_email
self.fb_token.get('/me/interests')
end
def get_fb_user_id
self.fb_token.get('/me/interests')
end
def authenticate
#if this fb_user_id is in the database, log them in otherwise don't
end
def is_valid?
if(try_access_token(self.access_token))
return true
else
return false
end
end
end
완벽합니다. 두 번째 단계로 넘어갈 때 이것은 분명합니다! 고맙습니다! – user531065