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

Includes before extends in model #5

Open
wants to merge 1 commit into
base: rails-3-2
Choose a base branch
from

Conversation

query-string
Copy link

In some cases, includes must follow before extends. For example, https://github.com/ai/r18n gem requires 'include R18n::Translated' before I call 'translations' method.

@hopsoft
Copy link
Owner

hopsoft commented Apr 23, 2013

My thought process here was somewhat hierarchical. First add functionality to the class then add functionality for instances.

Sometimes modules intended for inclusion will also extend the class. This is perfectly fine and should be OK to run after extend calls. The one caveat would be if an extend module has a dependency injected by an include module, but this should be an extremely rare case.

Remember that the model template is only a guide (with reasonable defaults). I still believe that extends belongs above includes in the guide as the default; however, it's certainly acceptable to bend the rule when needed.

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