I have an action in a controller that sends an api call to a 3rd party app. Part of the payload is a js code in a string format that the app stores.
Here's an illustration:
def store_code_on_app
myCode = "
function hello(you){
console.log("hello", you);
}
"
RestClient.post(
"http://theapp.com/codes/create",
{
code: myCode
}
)
end
Since my actual code is very long and to best manage multiple codes later on, I would like to store those codes in a file inside some folder in my rails app and call it from the controller. I would prefer to save the file with the appropriate extension (mycode.js) so it's easier to handle and debug.
How would you recommend I do that? Probably by requiring or including a file? perhaps in the lib folder?