I have a rails controller
class Controllername < application
def method1
obj = API_CALL
session =obj.access_token
redirect_to redirect_url #calls the API authorization end point
#and redirects to action method2
end
def method2
obj.call_after_sometime
end
end
I am calling some API's in method1 getting a object and storing access token and secrets in a session. method1
finishes it's action.
After sometime I am calling method2
, now the session(access token, secrets) is stored correctly.
But, now inside method2
I need to call the API call_after_sometime
using the OBJECT obj
.But, now obj
is unavailable because I didn't store it in a session(We will get a SSL error storing encrypted objects).
I want to know what's the best way to store obj
in method1
so that it can be used later in method2
EDIT:
when I tried Rails.cache or Session I am getting the error
TypeError - no _dump_data is defined for class OpenSSL::X509::Certificate
Googling it I found when I store encrypted values in session it will throw this error.