Prev | Current Page 427 | Next

Brad Ediger

"Advanced Rails"

This method involves having your MTA pipe
incoming mail to a command such as this:
script/runner 'Mailer.receive(STDIN.read)'
Do not do this except in the absolute simplest of cases. Using script/runner is very
computationally expensive, because it loads the entire Rails environment on each
invocation. Loading a Ruby interpreter with all of Rails for each incoming email is
ridiculous.
The standard method for processing incoming mail is to batch email in a mailbox
and have a process retrieve that mail at a regular interval. The mail can be retrieved
using Net::POP3 or Net::IMAP from the Ruby standard library.
If mail really needs to be processed immediately upon receipt, a custom solution,
even using Ruby and ActionMailer, will still be much faster than the preceding example
that loads all of Rails. But if you need immediate delivery, you should probably
first consider a solution like SMS or Jabber rather than SMTP.
Contributing to Rails
Rails, as an open source framework, benefits greatly from contributions from the
community. Rails incorporates code from hundreds of developers, not just the dozen
or so on the core team. Writing code to expand, extend, or fix Rails is often the best
way to learn about its internals.
Of course, not all functionality belongs in Rails itself. Rails is an opinionated framework,
so there are some defaults that may not be useful to everyone.


Pages:
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439