Topic: Temporarily saving data

Hi guys

I'm making an app for Twilio where I will perform several Redirects. The first selection callers will be able to make is the language selection, so obviously this needs to be remembered. The Twilio staff told me the call has an ID which I should be able to store, in order to decide which language to use after that initial redirect. I could store this in the database, but then it would be come bloated after a while with entries that I use only once.

What is the best way to solve this? I would say this ID and its selected language would only need to be remembered during the call, but let's take a day to keep it easy. I don't want to run some kind of "dumb" job that clears the table, as that might force something to go wrong in the middle of a call.

Thanks guys

Re: Temporarily saving data

If you want to hold state then use the session

session[:language] = chosen_language

then use it

chosen_language = session[:language]

It's what the session was designed for, to hold state in a stateless environment

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Temporarily saving data

Damn, so obvious. Why didn't I think of that. Cheers!

Re: Temporarily saving data

Actually, as a followup question... because I will be using Twilio and all these requests come from Twilio and not from separate clients, I'm not sure using sessions will work.

Let's assume it doesn't - what's the next best thing to do?

Re: Temporarily saving data

Why on earth would a session not work?
Let's assume that if session does not work then there is a bug in rails that no one has picked up on. highly unlikely I would think!
Perhaps if you could explain why you think sessions might not be appropriate I might be able to help but for the life of me I can think of no reason why a session would not meet your needs.
Perhaps you are over thinking this? sometimes it's best just to get on and do it!

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Temporarily saving data

I am indeed building this, will figure out soon enough :-)

The reason I fear it might not work (but I think it will) is that if you make a call to the Twilio number, Twilio's servers make a request to my app to get XML data. So if two people call at (nearly) the same time, it might be looked at as the same session? After all, the request to my app comes from the same place

Re: Temporarily saving data

Is twilio passing you anything unique in the request header on a per request basis? If so then perhaps you can make use of this in the session to uniquely identify the request?

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)