I am getting lots of push back from Rails because I have subclassed User into many different subclasses. In my application, not all users are equal. There\'s actually a lot
Here's a trick I figured out. Don't assume it's intended behaviour though:
class UserSubclass < User
def self.model_name
User.model_name
end
end
Basically all models (that derive from ActiveModel) identify themselves, by default, based on the concrete class name. That's done through the class method #model_name
(it returns an instance of ActiveModel::Name
with self
as the parameter. Overriding it to return a specific class puts Rails on the right track. This way you keep that logic in your model and out of your templates.