Skip to content

Instantly share code, notes, and snippets.

@sukima
Created August 6, 2010 19:21
Show Gist options
  • Save sukima/511836 to your computer and use it in GitHub Desktop.
Save sukima/511836 to your computer and use it in GitHub Desktop.
ActiveMailer syntax error
class ApplicationMailer < ActionMailer::Base
def welcome_email(instructor)
recipients instructor.email
from APP_CONFIG['system_email_address']
subject "Welcome to #{APP_CONFIG['application_name']}. Thank you for registering."
sent_on Time.now
body {:instructor => instructor}
end
end
suki[SimNotify] (feature/mailer)$ script/console
Loading development environment (Rails 2.3.8)
>> ApplicationMailer.deliver_welcome_email("test")
SyntaxError: /Users/suki/source/SimNotify/app/models/application_mailer.rb:7: syntax error, unexpected tASSOC, expecting '}'
body {:instructor => instructor}
^
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:380:in `load_file'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:379:in `load_file'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:259:in `require_or_load'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:425:in `load_missing_constant'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing'
from (irb):1
>>
@sukima
Copy link
Author

sukima commented Aug 6, 2010

Attempting to use the examples from Action Mailer Basics will cause the above error. Instead remove the curly brackets:

body           :instructor => instructor

This will work. I have no idea why the docs say otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment