Skip to content

Commit c2708c0

Browse files
juno-nishizakiRedmine Patch Meetup
authored andcommitted
第23回 viewに実装していた処理をhelperに切り出した
1 parent efc58e3 commit c2708c0

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

app/helpers/mailer_helper.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
# Redmine - project management software
4+
# Copyright (C) 2006-2022 Jean-Philippe Lang
5+
#
6+
# This program is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU General Public License
8+
# as published by the Free Software Foundation; either version 2
9+
# of the License, or (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
20+
module MailerHelper
21+
def show_recipients(recipients)
22+
recipients.take(Setting.show_recipients_limit.to_i).map(&:name).join(', ') + (recipients.size > Setting.show_recipients_limit.to_i ? '...' : '')
23+
end
24+
end

app/models/mailer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Mailer < ActionMailer::Base
2424
helper :application
2525
helper :issues
2626
helper :custom_fields
27+
helper :mailer
2728

2829
include Redmine::I18n
2930
include Roadie::Rails::Automatic

app/views/layouts/mailer.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ table, td, th {
8686
<% if Setting.show_recipients_in_mail_footer? && @recipients.present? %>
8787
<span class="recipients">
8888
<%= l(:text_sent_email_to_recipients) %><br>
89-
<%= @recipients.take(Setting.show_recipients_limit.to_i).map(&:name).join(', ') %><%= '...' if @recipients.size > Setting.show_recipients_limit.to_i %>
89+
<%= show_recipients @recipients %>
9090
</span>
9191
<% end %>
9292
</body>

app/views/layouts/mailer.text.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
<% if Setting.show_recipients_in_mail_footer? && @recipients.present? %>
1010

1111
<%= l(:text_sent_email_to_recipients) %>
12-
<%= @recipients.take(Setting.show_recipients_limit.to_i).map(&:name).join(', ') %><%= '...' if @recipients.size > Setting.show_recipients_limit.to_i %>
12+
<%= show_recipients @recipients %>
1313
<% end -%>

0 commit comments

Comments
 (0)