@@ -23,13 +23,13 @@ module ActionMailer
23
23
# Examples:
24
24
#
25
25
# class Notifier < ActionMailer::Base
26
- # default : from => '[email protected] ',
27
- # : return_path => '[email protected] '
26
+ # default from: '[email protected] ',
27
+ # return_path: '[email protected] '
28
28
#
29
29
# def welcome(recipient)
30
30
# @account = recipient
31
- # mail(:to => recipient.email_address_with_name,
32
- # : bcc => ["[email protected] ", "Order Watcher <[email protected] >"])
31
+ # mail(to: recipient.email_address_with_name,
32
+
33
33
# end
34
34
# end
35
35
#
@@ -62,21 +62,21 @@ module ActionMailer
62
62
#
63
63
# If you want to explicitly render only certain templates, pass a block:
64
64
#
65
- # mail(:to => user.email) do |format|
65
+ # mail(to: user.email) do |format|
66
66
# format.text
67
67
# format.html
68
68
# end
69
69
#
70
70
# The block syntax is also useful in providing information specific to a part:
71
71
#
72
- # mail(:to => user.email) do |format|
72
+ # mail(to: user.email) do |format|
73
73
# format.text(:content_transfer_encoding => "base64")
74
74
# format.html
75
75
# end
76
76
#
77
77
# Or even to render a special view:
78
78
#
79
- # mail(:to => user.email) do |format|
79
+ # mail(to: user.email) do |format|
80
80
# format.text
81
81
# format.html { render "some_other_template" }
82
82
# end
@@ -100,12 +100,12 @@ module ActionMailer
100
100
# You can even use Action Pack helpers in these views. For example:
101
101
#
102
102
# You got a new note!
103
- # <%= truncate(@note.body, : length => 25) %>
103
+ # <%= truncate(@note.body, length: 25) %>
104
104
#
105
105
# If you need to access the subject, from or the recipients in the view, you can do that through message object:
106
106
#
107
107
# You got a new note from <%= message.from %>!
108
- # <%= truncate(@note.body, : length => 25) %>
108
+ # <%= truncate(@note.body, length: 25) %>
109
109
#
110
110
#
111
111
# = Generating URLs
@@ -116,11 +116,11 @@ module ActionMailer
116
116
#
117
117
# When using <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>:
118
118
#
119
- # <%= url_for(: host => "example.com", : controller => "welcome", : action => "greeting") %>
119
+ # <%= url_for(host: "example.com", controller: "welcome", action: "greeting") %>
120
120
#
121
121
# When using named routes you only need to supply the <tt>:host</tt>:
122
122
#
123
- # <%= users_url(: host => "example.com") %>
123
+ # <%= users_url(host: "example.com") %>
124
124
#
125
125
# You should use the <tt>named_route_url</tt> style (which generates absolute URLs) and avoid using the
126
126
# <tt>named_route_path</tt> style (which generates relative URLs), since clients reading the mail will
@@ -176,7 +176,7 @@ module ActionMailer
176
176
# class ApplicationMailer < ActionMailer::Base
177
177
# def welcome(recipient)
178
178
# attachments['free_book.pdf'] = File.read('path/to/file.pdf')
179
- # mail(:to => recipient, : subject => "New account information")
179
+ # mail(to: recipient, subject: "New account information")
180
180
# end
181
181
# end
182
182
#
@@ -192,7 +192,7 @@ module ActionMailer
192
192
# class ApplicationMailer < ActionMailer::Base
193
193
# def welcome(recipient)
194
194
# attachments['free_book.pdf'] = File.read('path/to/file.pdf')
195
- # mail(:to => recipient, : subject => "New account information", : body => "")
195
+ # mail(to: recipient, subject: "New account information", body: "")
196
196
# end
197
197
# end
198
198
#
@@ -204,7 +204,7 @@ module ActionMailer
204
204
# class ApplicationMailer < ActionMailer::Base
205
205
# def welcome(recipient)
206
206
# attachments.inline['photo.png'] = File.read('path/to/photo.png')
207
- # mail(:to => recipient, : subject => "Here is what we look like")
207
+ # mail(to: recipient, subject: "Here is what we look like")
208
208
# end
209
209
# end
210
210
#
@@ -220,7 +220,7 @@ module ActionMailer
220
220
#
221
221
# <h1>Please Don't Cringe</h1>
222
222
#
223
- # <%= image_tag attachments['photo.png'].url, : alt => 'Our Photo', : class => 'photo' -%>
223
+ # <%= image_tag attachments['photo.png'].url, alt: 'Our Photo', class: 'photo' -%>
224
224
#
225
225
# = Observing and Intercepting Mails
226
226
#
@@ -241,7 +241,7 @@ module ActionMailer
241
241
# default method inside the class definition:
242
242
#
243
243
# class Notifier < ActionMailer::Base
244
- # default : sender => '[email protected] '
244
+ # default sender: '[email protected] '
245
245
# end
246
246
#
247
247
# You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box,
@@ -260,7 +260,7 @@ module ActionMailer
260
260
#
261
261
# class Notifier < ActionMailer::Base
262
262
# default 'Content-Transfer-Encoding' => '7bit',
263
- # : content_description => 'This is a description'
263
+ # content_description: 'This is a description'
264
264
# end
265
265
#
266
266
# Finally, Action Mailer also supports passing <tt>Proc</tt> objects into the default hash, so you
@@ -386,10 +386,10 @@ class Base < AbstractController::Base
386
386
387
387
class_attribute :default_params
388
388
self . default_params = {
389
- : mime_version => "1.0" ,
390
- : charset => "UTF-8" ,
391
- : content_type => "text/plain" ,
392
- : parts_order => [ "text/plain" , "text/enriched" , "text/html" ]
389
+ mime_version : "1.0" ,
390
+ charset : "UTF-8" ,
391
+ content_type : "text/plain" ,
392
+ parts_order : [ "text/plain" , "text/enriched" , "text/html" ]
393
393
} . freeze
394
394
395
395
class_attribute :queue
@@ -549,17 +549,17 @@ def headers(args=nil)
549
549
#
550
550
# You can also specify overrides if you want by passing a hash instead of a string:
551
551
#
552
- # mail.attachments['filename.jpg'] = {: mime_type => 'application/x-gzip',
553
- # : content => File.read('/path/to/filename.jpg')}
552
+ # mail.attachments['filename.jpg'] = {mime_type: 'application/x-gzip',
553
+ # content: File.read('/path/to/filename.jpg')}
554
554
#
555
555
# If you want to use a different encoding than Base64, you can pass an encoding in,
556
556
# but then it is up to you to pass in the content pre-encoded, and don't expect
557
557
# Mail to know how to decode this data:
558
558
#
559
559
# file_content = SpecialEncode(File.read('/path/to/filename.jpg'))
560
- # mail.attachments['filename.jpg'] = {: mime_type => 'application/x-gzip',
561
- # : encoding => 'SpecialEncoding',
562
- # : content => file_content }
560
+ # mail.attachments['filename.jpg'] = {mime_type: 'application/x-gzip',
561
+ # encoding: 'SpecialEncoding',
562
+ # content: file_content }
563
563
#
564
564
# You can also search for specific attachments:
565
565
#
@@ -597,9 +597,9 @@ def attachments
597
597
# class method:
598
598
#
599
599
# class Notifier < ActionMailer::Base
600
- # self.default : from => '[email protected] ',
601
-
602
- # : reply_to => '[email protected] '
600
+ # self.default from: '[email protected] ',
601
+
602
+
603
603
# end
604
604
#
605
605
# If you need other headers not listed above, you can either pass them in
@@ -621,10 +621,10 @@ def attachments
621
621
# For example:
622
622
#
623
623
# class Notifier < ActionMailer::Base
624
- # default : from => '[email protected] ',
624
+ # default from: '[email protected] ',
625
625
#
626
626
# def welcome
627
- # mail(:to => '[email protected] ')
627
+
628
628
# end
629
629
# end
630
630
#
@@ -633,22 +633,22 @@ def attachments
633
633
#
634
634
# However, those can be customized:
635
635
#
636
- # mail(: template_path => 'notifications', : template_name => 'another')
636
+ # mail(template_path: 'notifications', template_name: 'another')
637
637
#
638
638
# And now it will look for all templates at "app/views/notifications" with name "another".
639
639
#
640
640
# If you do pass a block, you can render specific templates of your choice:
641
641
#
642
- # mail(:to => '[email protected] ') do |format|
642
+ # mail(to: '[email protected] ') do |format|
643
643
# format.text
644
644
# format.html
645
645
# end
646
646
#
647
647
# You can even render text directly without using a template:
648
648
#
649
- # mail(:to => '[email protected] ') do |format|
650
- # format.text { render : text => "Hello Mikel!" }
651
- # format.html { render : text => "<h1>Hello Mikel!</h1>" }
649
+ # mail(to: '[email protected] ') do |format|
650
+ # format.text { render text: "Hello Mikel!" }
651
+ # format.html { render text: "<h1>Hello Mikel!</h1>" }
652
652
# end
653
653
#
654
654
# Which will render a <tt>multipart/alternative</tt> email with <tt>text/plain</tt> and
@@ -657,7 +657,7 @@ def attachments
657
657
# The block syntax also allows you to customize the part headers if desired:
658
658
#
659
659
# mail(:to => '[email protected] ') do |format|
660
- # format.text(: content_transfer_encoding => "base64")
660
+ # format.text(content_transfer_encoding: "base64")
661
661
# format.html
662
662
# end
663
663
#
@@ -730,7 +730,7 @@ def set_content_type(m, user_content_type, class_default)
730
730
# humanized version of the <tt>action_name</tt>.
731
731
def default_i18n_subject #:nodoc:
732
732
mailer_scope = self . class . mailer_name . tr ( '/' , '.' )
733
- I18n . t ( :subject , : scope => [ mailer_scope , action_name ] , : default => action_name . humanize )
733
+ I18n . t ( :subject , scope : [ mailer_scope , action_name ] , default : action_name . humanize )
734
734
end
735
735
736
736
def collect_responses_and_parts_order ( headers ) #:nodoc:
@@ -743,8 +743,8 @@ def collect_responses_and_parts_order(headers) #:nodoc:
743
743
responses = collector . responses
744
744
elsif headers [ :body ]
745
745
responses << {
746
- : body => headers . delete ( :body ) ,
747
- : content_type => self . class . default [ :content_type ] || "text/plain"
746
+ body : headers . delete ( :body ) ,
747
+ content_type : self . class . default [ :content_type ] || "text/plain"
748
748
}
749
749
else
750
750
templates_path = headers . delete ( :template_path ) || self . class . mailer_name
@@ -754,8 +754,8 @@ def collect_responses_and_parts_order(headers) #:nodoc:
754
754
self . formats = template . formats
755
755
756
756
responses << {
757
- : body => render ( : template => template ) ,
758
- : content_type => template . type . to_s
757
+ body : render ( template : template ) ,
758
+ content_type : template . type . to_s
759
759
}
760
760
end
761
761
end
0 commit comments