forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update actionmailer with new hash syntax.
- Loading branch information
1 parent
918f703
commit 96f290e
Showing
15 changed files
with
169 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,13 @@ module ActionMailer | |
# Examples: | ||
# | ||
# class Notifier < ActionMailer::Base | ||
# default :from => '[email protected]', | ||
# :return_path => '[email protected]' | ||
# default from: '[email protected]', | ||
# return_path: '[email protected]' | ||
# | ||
# def welcome(recipient) | ||
# @account = recipient | ||
# mail(:to => recipient.email_address_with_name, | ||
# :bcc => ["[email protected]", "Order Watcher <[email protected]>"]) | ||
# mail(to: recipient.email_address_with_name, | ||
# bcc: ["[email protected]", "Order Watcher <[email protected]>"]) | ||
# end | ||
# end | ||
# | ||
|
@@ -62,21 +62,21 @@ module ActionMailer | |
# | ||
# If you want to explicitly render only certain templates, pass a block: | ||
# | ||
# mail(:to => user.email) do |format| | ||
# mail(to: user.email) do |format| | ||
# format.text | ||
# format.html | ||
# end | ||
# | ||
# The block syntax is also useful in providing information specific to a part: | ||
# | ||
# mail(:to => user.email) do |format| | ||
# mail(to: user.email) do |format| | ||
# format.text(:content_transfer_encoding => "base64") | ||
# format.html | ||
# end | ||
# | ||
# Or even to render a special view: | ||
# | ||
# mail(:to => user.email) do |format| | ||
# mail(to: user.email) do |format| | ||
# format.text | ||
# format.html { render "some_other_template" } | ||
# end | ||
|
@@ -100,12 +100,12 @@ module ActionMailer | |
# You can even use Action Pack helpers in these views. For example: | ||
# | ||
# You got a new note! | ||
# <%= truncate(@note.body, :length => 25) %> | ||
# <%= truncate(@note.body, length: 25) %> | ||
# | ||
# If you need to access the subject, from or the recipients in the view, you can do that through message object: | ||
# | ||
# You got a new note from <%= message.from %>! | ||
# <%= truncate(@note.body, :length => 25) %> | ||
# <%= truncate(@note.body, length: 25) %> | ||
# | ||
# | ||
# = Generating URLs | ||
|
@@ -116,11 +116,11 @@ module ActionMailer | |
# | ||
# When using <tt>url_for</tt> you'll need to provide the <tt>:host</tt>, <tt>:controller</tt>, and <tt>:action</tt>: | ||
# | ||
# <%= url_for(:host => "example.com", :controller => "welcome", :action => "greeting") %> | ||
# <%= url_for(host: "example.com", controller: "welcome", action: "greeting") %> | ||
# | ||
# When using named routes you only need to supply the <tt>:host</tt>: | ||
# | ||
# <%= users_url(:host => "example.com") %> | ||
# <%= users_url(host: "example.com") %> | ||
# | ||
# You should use the <tt>named_route_url</tt> style (which generates absolute URLs) and avoid using the | ||
# <tt>named_route_path</tt> style (which generates relative URLs), since clients reading the mail will | ||
|
@@ -176,7 +176,7 @@ module ActionMailer | |
# class ApplicationMailer < ActionMailer::Base | ||
# def welcome(recipient) | ||
# attachments['free_book.pdf'] = File.read('path/to/file.pdf') | ||
# mail(:to => recipient, :subject => "New account information") | ||
# mail(to: recipient, subject: "New account information") | ||
# end | ||
# end | ||
# | ||
|
@@ -192,7 +192,7 @@ module ActionMailer | |
# class ApplicationMailer < ActionMailer::Base | ||
# def welcome(recipient) | ||
# attachments['free_book.pdf'] = File.read('path/to/file.pdf') | ||
# mail(:to => recipient, :subject => "New account information", :body => "") | ||
# mail(to: recipient, subject: "New account information", body: "") | ||
# end | ||
# end | ||
# | ||
|
@@ -204,7 +204,7 @@ module ActionMailer | |
# class ApplicationMailer < ActionMailer::Base | ||
# def welcome(recipient) | ||
# attachments.inline['photo.png'] = File.read('path/to/photo.png') | ||
# mail(:to => recipient, :subject => "Here is what we look like") | ||
# mail(to: recipient, subject: "Here is what we look like") | ||
# end | ||
# end | ||
# | ||
|
@@ -220,7 +220,7 @@ module ActionMailer | |
# | ||
# <h1>Please Don't Cringe</h1> | ||
# | ||
# <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%> | ||
# <%= image_tag attachments['photo.png'].url, alt: 'Our Photo', class: 'photo' -%> | ||
# | ||
# = Observing and Intercepting Mails | ||
# | ||
|
@@ -241,7 +241,7 @@ module ActionMailer | |
# default method inside the class definition: | ||
# | ||
# class Notifier < ActionMailer::Base | ||
# default :sender => '[email protected]' | ||
# default sender: '[email protected]' | ||
# end | ||
# | ||
# You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box, | ||
|
@@ -260,7 +260,7 @@ module ActionMailer | |
# | ||
# class Notifier < ActionMailer::Base | ||
# default 'Content-Transfer-Encoding' => '7bit', | ||
# :content_description => 'This is a description' | ||
# content_description: 'This is a description' | ||
# end | ||
# | ||
# Finally, Action Mailer also supports passing <tt>Proc</tt> objects into the default hash, so you | ||
|
@@ -386,10 +386,10 @@ class Base < AbstractController::Base | |
|
||
class_attribute :default_params | ||
self.default_params = { | ||
:mime_version => "1.0", | ||
:charset => "UTF-8", | ||
:content_type => "text/plain", | ||
:parts_order => [ "text/plain", "text/enriched", "text/html" ] | ||
mime_version: "1.0", | ||
charset: "UTF-8", | ||
content_type: "text/plain", | ||
parts_order: [ "text/plain", "text/enriched", "text/html" ] | ||
}.freeze | ||
|
||
class_attribute :queue | ||
|
@@ -549,17 +549,17 @@ def headers(args=nil) | |
# | ||
# You can also specify overrides if you want by passing a hash instead of a string: | ||
# | ||
# mail.attachments['filename.jpg'] = {:mime_type => 'application/x-gzip', | ||
# :content => File.read('/path/to/filename.jpg')} | ||
# mail.attachments['filename.jpg'] = {mime_type: 'application/x-gzip', | ||
# content: File.read('/path/to/filename.jpg')} | ||
# | ||
# If you want to use a different encoding than Base64, you can pass an encoding in, | ||
# but then it is up to you to pass in the content pre-encoded, and don't expect | ||
# Mail to know how to decode this data: | ||
# | ||
# file_content = SpecialEncode(File.read('/path/to/filename.jpg')) | ||
# mail.attachments['filename.jpg'] = {:mime_type => 'application/x-gzip', | ||
# :encoding => 'SpecialEncoding', | ||
# :content => file_content } | ||
# mail.attachments['filename.jpg'] = {mime_type: 'application/x-gzip', | ||
# encoding: 'SpecialEncoding', | ||
# content: file_content } | ||
# | ||
# You can also search for specific attachments: | ||
# | ||
|
@@ -597,9 +597,9 @@ def attachments | |
# class method: | ||
# | ||
# class Notifier < ActionMailer::Base | ||
# self.default :from => '[email protected]', | ||
# :bcc => '[email protected]', | ||
# :reply_to => '[email protected]' | ||
# self.default from: '[email protected]', | ||
# bcc: '[email protected]', | ||
# reply_to: '[email protected]' | ||
# end | ||
# | ||
# If you need other headers not listed above, you can either pass them in | ||
|
@@ -621,10 +621,10 @@ def attachments | |
# For example: | ||
# | ||
# class Notifier < ActionMailer::Base | ||
# default :from => '[email protected]', | ||
# default from: '[email protected]', | ||
# | ||
# def welcome | ||
# mail(:to => '[email protected]') | ||
# mail(to: '[email protected]') | ||
# end | ||
# end | ||
# | ||
|
@@ -633,22 +633,22 @@ def attachments | |
# | ||
# However, those can be customized: | ||
# | ||
# mail(:template_path => 'notifications', :template_name => 'another') | ||
# mail(template_path: 'notifications', template_name: 'another') | ||
# | ||
# And now it will look for all templates at "app/views/notifications" with name "another". | ||
# | ||
# If you do pass a block, you can render specific templates of your choice: | ||
# | ||
# mail(:to => '[email protected]') do |format| | ||
# mail(to: '[email protected]') do |format| | ||
# format.text | ||
# format.html | ||
# end | ||
# | ||
# You can even render text directly without using a template: | ||
# | ||
# mail(:to => '[email protected]') do |format| | ||
# format.text { render :text => "Hello Mikel!" } | ||
# format.html { render :text => "<h1>Hello Mikel!</h1>" } | ||
# mail(to: '[email protected]') do |format| | ||
# format.text { render text: "Hello Mikel!" } | ||
# format.html { render text: "<h1>Hello Mikel!</h1>" } | ||
# end | ||
# | ||
# Which will render a <tt>multipart/alternative</tt> email with <tt>text/plain</tt> and | ||
|
@@ -657,7 +657,7 @@ def attachments | |
# The block syntax also allows you to customize the part headers if desired: | ||
# | ||
# mail(:to => '[email protected]') do |format| | ||
# format.text(:content_transfer_encoding => "base64") | ||
# format.text(content_transfer_encoding: "base64") | ||
# format.html | ||
# end | ||
# | ||
|
@@ -730,7 +730,7 @@ def set_content_type(m, user_content_type, class_default) | |
# humanized version of the <tt>action_name</tt>. | ||
def default_i18n_subject #:nodoc: | ||
mailer_scope = self.class.mailer_name.tr('/', '.') | ||
I18n.t(:subject, :scope => [mailer_scope, action_name], :default => action_name.humanize) | ||
I18n.t(:subject, scope: [mailer_scope, action_name], default: action_name.humanize) | ||
end | ||
|
||
def collect_responses_and_parts_order(headers) #:nodoc: | ||
|
@@ -743,8 +743,8 @@ def collect_responses_and_parts_order(headers) #:nodoc: | |
responses = collector.responses | ||
elsif headers[:body] | ||
responses << { | ||
:body => headers.delete(:body), | ||
:content_type => self.class.default[:content_type] || "text/plain" | ||
body: headers.delete(:body), | ||
content_type: self.class.default[:content_type] || "text/plain" | ||
} | ||
else | ||
templates_path = headers.delete(:template_path) || self.class.mailer_name | ||
|
@@ -754,8 +754,8 @@ def collect_responses_and_parts_order(headers) #:nodoc: | |
self.formats = template.formats | ||
|
||
responses << { | ||
:body => render(:template => template), | ||
:content_type => template.type.to_s | ||
body: render(template: template), | ||
content_type: template.type.to_s | ||
} | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
|
||
class AssetHostMailer < ActionMailer::Base | ||
def email_with_asset | ||
mail :to => 'test@localhost', | ||
:subject => 'testing email containing asset path while asset_host is set', | ||
:from => '[email protected]' | ||
mail to: 'test@localhost', | ||
subject: 'testing email containing asset path while asset_host is set', | ||
from: '[email protected]' | ||
end | ||
end | ||
|
||
|
Oops, something went wrong.