I am fiddling around with a Setting model (a modified version of
should scope settings by a domain_id. I have created a class accessor
so that I can set the domain_id in the model from the session.
The class looks a little like this:
class Setting < ActiveRecord::Base
#set a setting value by  notation
def self.=(var_name, value)
if self[var_name] != value
var_name = var_name.to_s
record = find(:first, :include => :setting_type, :conditions =>
['domain_id = ? AND var = ?', @@domain_id, var_name])
type = SettingType.find_by_var(var_name)
record = Setting.new(:setting_type => type)
record.value = value.to_yaml
#TODO why cant i just use @@domain_id???
record.domain = Domain.find(@@domain_id)
This seems to work but I would like to just use the value of
@@domain_id and apply it to the 'record' object like this:
record.domain_id = @@domain_id
except that doesn't work. I can't for the life of me work out why.
Every other time I access @@domain_id it grabs the value except in this
Any pointers would be greatly appreciated.