Newbie quesiton about inheritance single table

T

Tobias

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
 
T

Tobias

Tobias said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top