[Rails] Re: Getting data from the database only once

Bing Tan
Wed, 19 Jul 2006 11:31:12 -0000

Anand Srinu wrote:
> Hi,
>    I am a little bit new to ruby. I have a requirement that I need to
> get the data from the database. I need to do this many times in the
> whole application. But, I am looking for a way with which I can get the
> data from the database table only once and store it in some variable,
> and I can use it anywhere I want.(I am trying not to use the global
> variable for this purpose). Is there a way for this. Please respond a
> lttle bit quick.
>
> Thanks in advance.
>
> Regards,
> Anand

Hi Anand,

Using the .find or .find_by_sql commands will pull data from your
database and put it into an array. Having said that, they can all be
accessed in your controller quite easily.

I hope I answered your question.

thanks,

Bing

--
Posted via http://www.ruby-forum.com/.