On Aug 12, 10:52 pm, tispratik <[email protected]> wrote:
> Hi,
>
> Does anyone know of a good way of caching the constant variables in
> the model.
> I have constants in models whose values are based on finder methods.
>
> eg) TYPE_UNIV = Decode.find_by_name("University")
>
> When i access this constant from Controllers or Views or Model, i see
> a query running in DB each time.
>
> -Pratik

Are you seeing this in the development logs while browsing your site?
If so, this is because in development mode Rails reloads your models,
controllers, and views with each request. And since I assume your
setting your constants in the toplevel class definition, they'll only
be reloaded every time appropriate model.rb file gets autoloaded.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to