Missing Hash Definition in Action Mailer Basics Guide Section 2.1.1

20 views
Skip to first unread message

Harrison Strowd

unread,
Feb 7, 2015, 3:16:38 PM2/7/15
to rubyonra...@googlegroups.com
In section 2.1.1 of the Action Mailer Basics Guide, the following code snippet is provided for setting up a basic action mailer:

# app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
  default "fr...@example.com"
  layout 'mailer'
end
 
# app/mailers/user_mailer.rb
class UserMailer < ApplicationMailer
end

Unfortunately this results in a TypeError of "no implicit conversion of String into Hash" because the default configuration method expects to receive a hash and not a string (see http://api.rubyonrails.org/classes/ActionMailer/Base.html#method-c-default). Instead, it appears that the following needs to be use:

# app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
  default from: "fr...@example.com"
  layout 'mailer'
end
 
# app/mailers/user_mailer.rb
class UserMailer < ApplicationMailer
end

This is also consistent with the similar code snippet provided in section 2.1.2. 

If I've misunderstood something here, just let me know. Thanks.
Reply all
Reply to author
Forward
0 new messages