Accessing class variable issues, hopefully a quick one

Hi all,

I am fiddling around with a Setting model (a modified version of
http://beautifulpixel.com/articles/2006/02/25/settings-plugin) that
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
belongs_to :domain

—snip —

    #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])
if record.nil?
type = SettingType.find_by_var(var_name)
record = Setting.new(:setting_type => type)
end
record.value = value.to_yaml

		#TODO why cant i just use @@domain_id????
		record.domain = Domain.find(@@domain_id)

		record.save
	end
end

end

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
case. Strange!

Any pointers would be greatly appreciated.

-felix