Forum: Ruby Newbie quesiton about inheritance single table

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tobias (Guest)
on 2007-01-21 14:25
(Received via mailing list)
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
Tobias (Guest)
on 2007-01-21 14:27
(Received via mailing list)
Tobias schrieb:

>  def self.find_employee
>
> Okay, if I run ruby script/console
>
> and then create an instance of Employee
> with e= Employee.new
>
> why is it so???
>
> Thanks for help
>
> Tobias

Sorry wrong ng
This topic is locked and can not be replied to.