9.6. Alternatives

Rails is opinionated software, and as such ships with a set of sensible defaults. As you have seen throughout this chapter, Rails assumes that you'll be using ERb, Builder, and RJS templates, and that you're going to employ Prototype and script.aculo.us. But it's important to understand that you are not limited to these options. Should you prefer a different template engine, you are free to adopt one instead of ERb. Common choices are Haml (http://haml.hamptoncatlin.com) and Liquid (http://www.liquidmarkup.org). If you'd like to simplify writing CSS, you can also check Haml's sister project, Saas.

Regarding Ajax, more than 200 frameworks are out there. Prototype is one of the best and most popular, but should you feel inclined to work with a different framework, you can copy it over in publicjavascripts, include it with javascript_include_tag, and then it will be ready for you to use whenever you like. Of course, you'd be using JavaScript, as opposed to comfortable Ruby wrappers, but you can always define your own Ruby helpers and perhaps share and distribute them with others as a plugin. In fact, many plugins for alternative JavaScript libraries exist or are under development at the moment.

One JavaScript library in particular has been gaining a lot of momentum: jQuery. It's very light, fast, powerful, and well written, and it's been able to catch the interest of many Rails developers. If you are among the legions of jQuery fans, you should use the jRails plugin (http://ennerchi.com/projects/jrails), which provides a drop-in jQuery replacement for Prototype and script.aculo.us.

There is then the matter of alternatives to Ajax. Quite a few people were able to successfully interface Adobe Flex and Rails, skipping Ajax altogether. Similarly, as IronRuby matures, it will be interesting to be able to deploy Silverlight (or its open source counterpart Moonlight) and Ruby on Rails in production mode, an effort that's already underway thanks to experimental plugins like Silverline (http://www.schementi.com/silverline).

Sending Emails

Ruby on Rails enables developers to send emails thanks to ActionMailer. In order for your application to be able to send emails, you'll mainly need to define a model that inherits from ActionMailer::Base and a mailer view that is a regular ERb template that represents the body of your email.

I highly recommend that you read the official Rails guide "Action Mailer Basics" to learn more about how to configure and use ActionMailer to send emails in your Rails applications. You can find it locally in doc (as discussed before) or online at http://guides.rubyonrails.org/action_mailer_basics.html.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.41.205