Skip to content

Instantly share code, notes, and snippets.

@greyblake
Created April 10, 2012 17:09
Show Gist options
  • Save greyblake/2352914 to your computer and use it in GitHub Desktop.
Save greyblake/2352914 to your computer and use it in GitHub Desktop.
ActionMailer bug?
# When everything work
class TestMailer < ActionMailer::Base
default :from => "[email protected]", :to => "[email protected]"
def hello
mail do |format|
format.text { render :text => "Hello!" }
format.html { render :text => "<h1>Hello!</h1>" }
end
end
end
hello_email = TestMailer.hello
hello_email.text_part.body.to_s # => "Hello!"
hello_email.html_part.body.to_s # => "<h1>Hello!</h1>"
##################################################################################
# When nothing works!!!
class TestMailer < ActionMailer::Base
default :from => "[email protected]", :to => "[email protected]"
def hello
mail do |format|
format.text { render :text => "Hello!" }
# We just commented it out
# format.html { render :text => "<h1>Hello!</h1>" }
end
end
end
hello_email = TestMailer.hello
hello_email.html_part # => nil, it's OK
hello_email.text_part # => nil, WTF?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment