Skip to content

Add _mailer suffix to generated file names. - #18074

Merged
rafaelfranca merged 1 commit into
rails:masterfrom
caike:master
Jan 6, 2015
Merged

Add _mailer suffix to generated file names.#18074
rafaelfranca merged 1 commit into
rails:masterfrom
caike:master

Conversation

@caike

@caike caike commented Dec 17, 2014

Copy link
Copy Markdown
Contributor

It is somewhat confusing that controllers and jobs follow this convention, but mailers don't.

@matthewd

Copy link
Copy Markdown
Member

Given that we're changing the existing behaviour, perhaps we could detect and silently ignore any trailing _mailer in the supplied name?

So,

rails generate mailer Notifications
rails generate mailer NotificationsMailer

would both generate the same thing?

If we're asserting that FooMailer is the "normal" choice of name, then presumably people are currently more likely to run the latter of those commands.

@caike

caike commented Dec 17, 2014

Copy link
Copy Markdown
Contributor Author

Excellent point! I'll work on that next.

@caike

caike commented Dec 18, 2014

Copy link
Copy Markdown
Contributor Author

Please let me know if there's a better way to prevent duplicate suffixes like I'm doing here.

I feel like there should be..

@rafaelfranca

Copy link
Copy Markdown
Member

The implementation looks good to me. @dhh what do you think about the convention change?

@dhh

dhh commented Jan 2, 2015

Copy link
Copy Markdown
Member

👍

@rafaelfranca

Copy link
Copy Markdown
Member

Great! @caike mind to add a CHANGELOG entry and squash your commits?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use sub here?

@_file_name ||= super.sub(/\_mailer\.rb$/i, '')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried your suggestion @JuanitoFatas , but looks like using sub this way doesn't account for removing duplicates. See the failure on MailerGeneratorTest#test_mailer_suffix_is_not_duplicated at https://travis-ci.org/rails/rails/jobs/46081505

Following the same naming convention used in
controllers and jobs.
rafaelfranca added a commit that referenced this pull request Jan 6, 2015
Add _mailer suffix to generated file names.
@rafaelfranca
rafaelfranca merged commit 5d28c6b into rails:master Jan 6, 2015
@rafaelfranca

Copy link
Copy Markdown
Member

❤️ 💚 💙 💛 💜

@carlosantoniodasilva

Copy link
Copy Markdown
Member

💚💛❤️💙💜

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the i18n path for the subject change as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! 👍
New PR submitted

@caike

caike commented Jan 9, 2015

Copy link
Copy Markdown
Contributor Author

Thanks for catching those @y-yagi ! 👍

rafaelfranca added a commit that referenced this pull request Feb 18, 2015
y-yagi added a commit to y-yagi/slim-rails that referenced this pull request Oct 7, 2016
In Rails 5, was forced as `_mailer` suffix is set.
Ref: rails/rails#18074
y-yagi added a commit to y-yagi/slim-rails that referenced this pull request Oct 7, 2016
In Rails 5, was forced as `_mailer` suffix is set.
Ref: rails/rails#18074
jamieblynn added a commit to jamieblynn/slim-rails that referenced this pull request Jan 30, 2022
In Rails 5, was forced as `_mailer` suffix is set.
Ref: rails/rails#18074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants