method in sub class unknown?

0 views
Skip to first unread message

kaatje

unread,
Jul 1, 2008, 9:14:41 AM7/1/08
to Dr Nic's Magic Models
I'm struggling with MMC. The connections to the different databases
work like a charm.
But when I define a method in a model, this method is unknown in the
subclass.

For example:

class Relationgroup < ActiveRecord::Base

set_primary_key "nummer"

has_many :relations, :foreign_key => 'rel_groepsnummer', :conditions
=> "rel_groepsnummer != ''", :order => "rel_naam"

def self.get_grpnumber
g = @mod::Relationgroup.find(:first, :order => "created_at
DESC", :limit => 1)
num = g.nummer[3,7].to_i + 1
"GRP" + num.to_s.rjust(5, "0")
end

end


In the controller:
@relationgroup = @mod::Relationgroup.new(params[:relationgroup])
@relationgroup.id = @relationgroup.get_grpnumber

Throws the following error:
undefined method `get_grpnumber' for
#<WegenerdbConnection::Relationgroup:0x436c9d8>


Please advice.

Orion Delwaterman

unread,
Jul 1, 2008, 10:51:55 AM7/1/08
to magic...@googlegroups.com
I'll take a look into the problem
Reply all
Reply to author
Forward
0 new messages