i have rails controller
class controllername < application def method1 obj = api_call session =obj.access_token redirect_to redirect_url #calls api authorization end point #and redirects action method2 end def method2 obj.call_after_sometime end end
i calling api's in method1 getting object , storing access token , secrets in session. method1
finishes it's action.
after sometime calling method2
, session(access token, secrets) stored correctly.
but, inside method2
need call api call_after_sometime
using object obj
.but, obj
unavailable because didn't store in session(we ssl error storing encrypted objects).
i want know what's best way store obj
in method1
can used later in method2
edit:
when tried rails.cache or session getting error
typeerror - no _dump_data defined class openssl::x509::certificate
googling found when store encrypted values in session throw error.
you can try caching it, careful of caching key, if object unique per user add user id in caching key
class controllername < application def method1 obj = api_call rails.cache.write("some_api_namespace/#{current_user.id}", obj) session =obj.access_token end def method2 obj = rails.cache.read("some_api_namespace/#{current_user.id}") obj.call_after_sometime end end
if there's possibility cache might not existent when try read it, use fetch
instead of read
call api if doesn't find data
def method2 obj = rails.cache.fetch("some_api_namespace/#{current_user.id}") method_1 end obj.call_after_sometime end
Comments
Post a Comment