method
create!

v2.1.0 - Show latest stable - 0 notes - Class: ActionMailer::Base
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
Related methods
- Class methods (29)
-
controller_path (>= v3.0.9)
-
default (>= v3.0.0)
-
default_options= (>= v4.0.2)
-
deliver
-
deliver_mail (>= v3.0.0)
-
email_address_with_name (>= v6.1.3.1)
-
mailer_name
-
matches_dynamic_method?
(>= v2.2.1)
-
method_missing
-
new
-
observer_class_for
(>= v5.0.0.1)
-
receive
-
register_interceptor (>= v3.0.9)
-
register_interceptors (>= v3.0.9)
-
register_observer (>= v3.0.9)
-
register_observers (>= v3.0.9)
-
register_template_extension
-
respond_to? (>= v2.2.1)
-
respond_to_missing?
(>= v5.0.0.1)
-
server_settings (<= v1.2.6)
-
server_settings= (<= v1.2.6)
-
set_payload_for_mail
(>= v3.0.0)
-
supports_path?
(>= v4.2.1)
-
template_root (>= v2.2.1)
-
template_root=
-
unregister_interceptor (>= v6.0.0)
-
unregister_interceptors (>= v6.0.0)
-
unregister_observer (>= v6.0.0)
-
unregister_observers (>= v6.0.0)
- Instance methods (42)
-
apply_defaults
(>= v5.0.0.1)
-
assign_headers_to_message
(>= v5.0.0.1)
-
attachments (>= v3.0.0)
-
candidate_for_layout?
(>= v2.2.1)
-
collect_responses
(>= v4.0.2)
-
collect_responses_and_parts...
(>= v3.0.0)
-
collect_responses_from_block
(>= v6.0.0)
-
collect_responses_from_temp...
(>= v5.0.0.1)
-
collect_responses_from_text
(>= v5.1.7)
-
compute_default
(>= v5.1.7)
-
controller_name
-
controller_path
-
create!
-
create_mail
-
create_parts_from_responses
(>= v3.0.0)
-
default_i18n_subject
(>= v3.0.0)
-
default_template_format
(>= v2.2.1)
-
deliver!
-
each_template
(>= v3.0.0)
-
email_address_with_name (>= v6.1.3.1)
-
headers (>= v3.0.0)
-
initialize_defaults
-
initialize_template_class
-
insert_part
(>= v3.0.0)
-
instrument_name
(>= v5.0.0.1)
-
instrument_payload
(>= v5.0.0.1)
-
mail (>= v3.0.0)
-
mailer_name
-
mailer_name=
-
perform_delivery_sendmail
-
perform_delivery_smtp
-
perform_delivery_test
-
process (>= v3.0.0)
-
_protected_ivars (>= v4.1.8)
-
render
-
render_message
-
set_content_type
(>= v3.0.0)
-
sort_parts
-
template_path
-
template_root
(>= v2.2.1)
-
template_root=
(>= v2.2.1)
-
wrap_inline_attachments
(>= v6.1.3.1)
= private
= protected
create!(method_name, *parameters)
public Initialize the mailer via the given method_name. The body will be rendered and a new TMail::Mail object created.
Show source
# File actionmailer/lib/action_mailer/base.rb, line 444 def create!(method_name, *parameters) #:nodoc: initialize_defaults(method_name) __send__(method_name, *parameters) # If an explicit, textual body has not been set, we check assumptions. unless String === @body # First, we look to see if there are any likely templates that match, # which include the content-type in their file name (i.e., # "the_template_file.text.html.erb", etc.). Only do this if parts # have not already been specified manually. if @parts.empty? templates = Dir.glob("#{template_path}/#{@template}.*") templates.each do |path| basename = File.basename(path) template_regex = Regexp.new("^([^\\\.]+)\\\.([^\\\.]+\\\.[^\\\.]+)\\\.(" + template_extensions.join('|') + ")$") next unless md = template_regex.match(basename) template_name = basename content_type = md.captures[1].gsub('.', '/') @parts << Part.new(:content_type => content_type, :disposition => "inline", :charset => charset, :body => render_message(template_name, @body)) end unless @parts.empty? @content_type = "multipart/alternative" @parts = sort_parts(@parts, @implicit_parts_order) end end # Then, if there were such templates, we check to see if we ought to # also render a "normal" template (without the content type). If a # normal template exists (or if there were no implicit parts) we render # it. template_exists = @parts.empty? template_exists ||= Dir.glob("#{template_path}/#{@template}.*").any? { |i| File.basename(i).split(".").length == 2 } @body = render_message(@template, @body) if template_exists # Finally, if there are other message parts and a textual body exists, # we shift it onto the front of the parts and set the body to nil (so # that create_mail doesn't try to render it in addition to the parts). if !@parts.empty? && String === @body @parts.unshift Part.new(:charset => charset, :body => @body) @body = nil end end # If this is a multipart e-mail add the mime_version if it is not # already set. @mime_version ||= "1.0" if !@parts.empty? # build the mail object itself @mail = create_mail end