James Coglan
9/2/2008 11:14:00 AM
[Note: parts of this message were removed to make it a legal post.]
> I see this example over and over.. where are the equal's signs???
>
> class Notifier < ActionMailer::Base
> def signup_notification(recipient)
> recipients recipient.email_address_with_name
> from "system@example.com"
> subject "New account information"
> body :account => recipient
> end
> end
You need = signs for assignment. In ActionMailer those are implemented as
methods to make the syntax a bit cleaner. A more verbose way to write the
above using full method call syntax:
class Notifier < ActionMailer::Base
def signup_notification(recipient)
self.recipients(recipient.email_address_with_name)
self.from("system@example.com")
self.subject("New account information")
self.body(:account => recipient)
end
end
This is why Ruby is known for being a good language for writing DSLs
(domain-specific languages, ie mini-languages for describing specific
problems), since its method call syntax does not require 'self' and lots of
parentheses.