Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call model.model_name.name instead of model.class.name to determine responder path. #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

undergroundwebdesigns
Copy link

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

…esponder path.

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.

See also http://stackoverflow.com/questions/29527156/rails-sti-override-model-name-in-parent-class-for-all-subclasses
@apotonick
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants