Alexey M. wrote in post #1018529:
In fact, i’ve got a problem in Rails with an abstract class
class AbstractSmartModel < ActiveRecord::Base
self.abstract_class = true
…
end
Inside a class, but outside any method definitions, self equals the
class. So the line:
self.abstract_class = true
is equivalent to:
AbstractSmartModel.abstract_class = true
I’ve got an error "Could not find table ‘abstract_smarter_models’ ".
I don’t know what that indicates.
I thought that one of the descendants called a method of
AbstractSmartModel
which called another method that only a non-abstract class could have,
but apparently i was wrong.
I’ll try to debug this, sorry for bad question.
UPDATE: the error is raised by a call to
columns_hash inside of a class method of the abstract class.
Do not understand.
If you have something like this:
class AbstractSmartModel < ActiveRecord::Base
self.abstract_class = true
def AbstractSmartModel.do_stuff
columns_hash(…)
end
end
The you are going to be calling the do_stuff() method like this:
AbstractSmartModel.do_stuff
…which means that inside the do_stuff() method, self is going to be
equal to AbstractSmartModel. From my previous post, you know that the
method call:
columns_hash()
is equivalent to:
self.columns_hash()
and because self=AbstractSmartModel, that line is equivalent to:
AbastractSmartModel.columns_hash()