I tried to simulate variable_set and variable_get in drupal which use as site-wide variables storage. I tried something like this.
# == Schema Information
# Schema version: 20091212170012
#
# Table name: variables
#
# id :integer not null, primary key
# name :string(255)
# value :text
# created_at :datetime
# updated_at :datetime
#
class Variable < ActiveRecord::Base
serialize :value
validates_uniqueness_of :name
validates_presence_of :name, :value
def self.set(name, value)
v = Variable.new()
v.name = name
v.value = value
v.save
end
def self.get(name)
Variable.find_by_name(name).value
end
end
but it doesn't work.