Skip to content

Instantly share code, notes, and snippets.

@greyblake
Created April 10, 2012 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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 => "from@example.com", :to => "to@example.com"
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 => "from@example.com", :to => "to@example.com"
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