1
내 세션 컨트롤러 프로세스 중 일부를 Resque 작업자로 이동하여 훨씬 더 원활하게 로그인하도록하려고합니다. 여기에서 부품을 이동하려는 :이 컨트롤러 코드를 Resque 작업으로 옮기는 방법은 무엇입니까?
def create
auth = request.env["omniauth.auth"]
omniauth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth,omniauth)
session[:user_id] = user.id
session['fb_auth'] = request.env['omniauth.auth']
session['fb_access_token'] = omniauth['credentials']['token']
session['fb_error'] = nil
@graph = Koala::Facebook::GraphAPI.new(current_user.token)
current_user.profile = @graph.get_object("me")
current_user.likes = @graph.get_connections("me", "likes")
current_user.friends = @graph.get_connections("me", "friends")
current_user.save
redirect_to root_url
end
을 Resque 근로자 (가/작업에?) 나는 그 작업자 작업을 초기화하는 세션 컨트롤러에 무엇을 추가 할
#ResqueFacebook.rb
require 'resque-retry'
Class FBResque
def self.perform()
@graph = Koala::Facebook::GraphAPI.new(current_user.token)
current_user.profile = @graph.get_object("me")
current_user.likes = @graph.get_connections("me", "likes")
current_user.friends = @graph.get_connections("me", "friends")
current_user.save
end
End
속으로? 또한 세션에 더 이상 존재하지 않으므로 current_user는 nil 객체가됩니다. 그러면 Worker의 코드가 User 루프의 사용자가되어야할까요?
이 사진을 줄 것입니다. 음,별로 모르겠다. 오케이. 'fb_connections' 심볼을 설명해 주시겠습니까? – Simpleton
@Simpleton 당신이 아직 그것을 알아 내지 못했다면 그 큐의 이름을 넣으십시오. – Autodidact
@Millisami 예. 내가 그때 어떻게 상징을 이해하지 못했는지 파악하기가 어렵다. – Simpleton