I have a table of companies and a join table forming the relationship
between a list of possible services they can provide.
Working from a basic understanding of OOP I assumed that there should be
a series of Serviceprovider child objects of the company class.
Company < ActiveRecord::Base
has_belongs_to_many :services
end
Serviceprovidertype1 < Company
Serviceprovidertype2 < Company
These child classes have corresponding child controllers
Serviceprovidertype1Controller < CompanyController
in the parent I have a method
protected
list_by_service(service)
Company.find_by_sql(.. + service + ...)
end
and in the child Serviceprovidertype1Controller
list
list_by_service(''Servicetype'')
end
but it only seems to work if I make the method in the parent a class
method ie
Company.list_by_service(service)
I don''t understand why the child just doesn''t inherit the
parent method,
and why a class method should - I''ve read it''s used when you
want it
to apply the same to all object instances ie
count_the_number of companies
Can anyone explain what I''ve obviously misunderstook, is my appraoch
using inheritance in this manner inappropriate ?
_tony
--
Posted via http://www.ruby-forum.com/.