[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Newbie quesiton about inheritance single table

Tobias

1/21/2007 1:04:00 PM

Hello ng,

person.rb:
_____________________________
class Person < ActiveRecord::Base

def initialize(mytype)
@type=mytype.to_s
end

def self.find_employee
find(:all, :conditions => "type='Employee''")
end


end

class Employee < Person
def initialize
super('Employee')
end

end

class Manager < Person
def initialize
super('Manager')
end

end
____________________

Okay, if I run ruby script/console
and create an instance of Employee with :
e= Employee.new

following error displayed:

uninitialized Constant Employee

if I first create a Person with:

p= Person.new('Bla Bla')

and then create an instance of Employee
with e= Employee.new

why is it so???

Thanks for help

Tobias

1 Answer

Tobias

1/21/2007 1:10:00 PM

0


Tobias schrieb:

> Hello ng,
>
> person.rb:
> _____________________________
> class Person < ActiveRecord::Base
>
> def initialize(mytype)
> @type=mytype.to_s
> end
>
> def self.find_employee
> find(:all, :conditions => "type='Employee''")
> end
>
>
> end
>
> class Employee < Person
> def initialize
> super('Employee')
> end
>
> end
>
> class Manager < Person
> def initialize
> super('Manager')
> end
>
> end
> ____________________
>
> Okay, if I run ruby script/console
> and create an instance of Employee with :
> e= Employee.new
>
> following error displayed:
>
> uninitialized Constant Employee
>
> if I first create a Person with:
>
> p= Person.new('Bla Bla')
>
> and then create an instance of Employee
> with e= Employee.new
>
> why is it so???
>
> Thanks for help
>
> Tobias

Sorry wrong ng