I have a module as shown below and when I extend an active record to
use it, I can not access the
primary_key method. In a simple test program using a similar approach
where active record is not involved, access to the class methods seems
to work ok. What can I do to make this work or so that I can access
the class methods ?
##################################
require ‘active_record’
DB_Host = ‘localhost’
DB_Database = ‘proj1’
DB_Port = 5432
ActiveRecord::Base.establish_connection(
:adapter => “postgresql”,
:host => DB_Host,
:database => DB_Database,
:username => “me”
:password => “secret”
)
module ModelClassMethods
def mycreate(pkey_val)
pkey_fld = self.primary_key
end
end
class ActiveNode < ActiveRecord::Base
extend ModelClassMethods
include ModelMethods
end