I want to create a base class for a few of my models, as follows:
class SingletonRecord < ActiveRecord::Base
def self.get
instance = self.find_all[0]
instance ||= Current.new
return instance
end
def save
self.delete_all
super
end
end
Then I create a subclass model like so:
require ‘singletonrecord’
class Current < SingletonRecord
end
This works great in the console, i.e. Current.get does what I’d expect.
But it doesn’t work through the web interface - it tells me
“SingletonRecord uninitialized constant”.
Why?