Thanks, this sounds like what I need.
On Feb 22, 7:24 pm, Jeff Lewis wrote:
> To initialize some db-read var (tidbit in your example) that would
> survive and be callable for each subsequent app request, you'll want
> to do so via lazy-initialization using a before_filter (mentioned by
> bill) i
hi,
Ruby pocket reference looks useful, think I'll order a copy.
Regarding the class method, just wondering when/how this method should
get called.
Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby
on Rail
For actual read-only data that is an instance of a model class, I'd
set up a class method instead. So for a default location, in
Location.rb,
def self.default_location
@@default_location ||= Location.find_by_name("San Francisco")
end
This fixes your migration problem, doesn't reload it with ev
To initialize some db-read var (tidbit in your example) that would
survive and be callable for each subsequent app request, you'll want
to do so via lazy-initialization using a before_filter (mentioned by
bill) in application.rb.
How you store such lazy-init vars between requests depends on the
s
Hi Eric,
On Sat, 2009-02-21 at 12:45 -0800, ericindc wrote:
> Title pretty much explains it. I'd like to set a variable the stores
> a single Model object inside of application.rb since it will be used
> on every single page. I've tried both class and instance variables,
> but to no avail. The
I don't generally follow the "whatever works..." approach because
there is usually a best practice. That said, I want to avoid the
global variable because having $tidbit = Tidbit.random declared in my
application.rb broke my migrations. Running migrations from version 0
when the Tidbits database
So why not use that, then? Whatever works...
Also, you might brush up on MVC and beginner's Ruby as far as "setting
variables in models" go:
http://wiki.rubyonrails.org/rails/pages/UnderstandingRailsMVC
On Feb 21, 12:45 pm, ericindc wrote:
> Title pretty much explains it. I'd like to set a var
7 matches
Mail list logo