Open undergroundwebdesigns opened 9 years ago
This implies that you have a "Rails model" in your hands, which is a wrong assumption, as many people render and parse arbitrary domain objects!!! We can make the name computation overridable if that helps?
Just letting you know I do not support roar-rails frequently anymore as I'm not interested in Roar and Rails without Trailblazer.
In TRB:
def create
run Comment::Create, representer: ->(options) { compute representer here, just for you }
end
ActiveModel supports a #model_name method which returns a class providing information about the model name, and removes the need to infer this from the class heirarchy.
The default model_name can also be over-ridden, which is especially useful to have rails treat all sub-classes of an STI base model the same (using the base path) for view and other related file lookups. This change makes that same over-ride also apply to representer lookups.
See also http://stackoverflow.com/questions/29527156/rails-sti-override-model-name-in-parent-class-for-all-subclasses