Accessing controller specific variables application-wide

Not sure if I described this the best in the subject, but here is my problem...

I have a 'settings' table, that I am storing application configuration data. On my settings "edit" page, I am just grabbing the first entry (you can't add more entries, again, just a config table)

[code]

@setting = Setting.find(1)

[/code]

I need to access some of that data in the main layout. For instance, the color (hex) of the template. The "name" of the application, etc.

How would I go about doing that?

Many ways to do this. Either declare a before_filter in application.rb and load the settings every time

before_filter :load_settings

def load_settings   @setting = Setting.find(1) end

Or, if you don't need it that often, you can define a method

def get_settings   @setting ||= Setting.find(1) end

This will load the setting the first time it's called. If it was called before, it just returns the @setting