I try to store a token in my localstorage from a ruby variable, As I understood, you can only set LocalStorage with Javascript, So here is my question, how can I pass my variable from Ruby to Javascript ? I saw some answers with script tag in the view, but is there any solution to do it directly in the app.js folder ?
So here is my Controller :
@token = HTTParty.post('https://test.pro/2.0/auth/token/access',
body: {
client_id: XXX,
client_secret: "YYYYYYYYYYYYYY",
code: LLLLLL
}
)
And in my view if I do a <%= @token %>, I have the following result :
{"access_token": "1VwCAjhsfCsdEoBoQs1G9kLHKoWOcJjamyj1s8_NQPrHeGNagzYYFrXKp_VlY", "token_type": "Bearer"}
Thanks for your help !