Let’s consider the following example:
class Ball < ActiveRecord::Base
def is_ball?
true
end
end
class BlueBall < Ball
def color
:blue
end
end
class RedBall < Ball
def color
:red
end
end
When I do Ball.find(id), is it possible to have an instance of BlueBall returned?
With Ball.where(owner: some_user).to_a could I get an array with BlueBall and RedBall instances?
I am looking for a way to explicitly set an STI by using some column other that type.
This could work if it’s possible to rename your classes
RedandBlueinstead ofRedBallandBlueBall