What Is Ruby on Rails
Pages: 1, 2, 3, 4, 5, 6, 7
Action Mailer
Action Mailer is a simple facility for sending and receiving email in your web application. Here's a method that sends an email with an attachment:
# send email with attachment
def signup_notification(recipient)
recipients recipient.email_address_with_name
subject "New account information"
from "system@example.com"
attachment :content_type => "image/jpeg", :body => File.read("an-image.jpg")
attachment "application/pdf" do |a|
a.body = generate_your_pdf_here()
end
end
To learn more, see the Action Mailer API, and Chapter 19 of the book Agile Web Development with Rails.
Action Web Service
Action Web Service implements server-side support for the SOAP and XML-RPC web service protocols and makes it easy for you to create web service APIs and publish them via WSDL.
Here is part of the MetaWeblog API as implemented by Typo (open source weblog software written in Rails):
class MetaWeblogApi < ActionWebService::API::Base
api_method :getRecentPosts,
:expects => [ {:blogid => :string},
{:username => :string},
{:password => :string},
{:numberOfPosts => :int} ],
:returns => [[MetaWeblogStructs::Article]]
api_method :deletePost,
:expects => [ {:appkey => :string},
{:postid => :string},
{:username => :string},
{:password => :string},
{:publish => :int} ],
:returns => [:bool]
end
class MetaWeblogService < TypoWebService
web_service_api MetaWeblogApi
def getRecentPosts(blogid, username, password, numberOfPosts)
articles = Article.find_all(nil, "created_at DESC", numberOfPosts)
articles.to_a.collect{ |c| article_dto_from(c) }
end
def deletePost(appkey, postid, username, password, publish)
article = Article.find(postid)
article.destroy
true
end
end
This snippet shows only two of the seven API methods defined in this class by Typo.
To learn more, see the Action Web Service Manual.
Parting Thoughts
You can usually divide web application frameworks and the developers who use them into two distinct categories. At one end of the spectrum, you have the heavy-duty frameworks for the "serious" developers, and at the other end you have the lightweight, easy-to-use frameworks for the "toy" developers. Each of these groups generally regards the other with disdain.
One of the most interesting things is that Rails is attracting developers from both camps. The high-end developers are tired of the repetitive, low-productivity routine that they have been forced to endure, while the low-end developers are tired of battling a mess of unmanageable code when their web apps move beyond the simple. Both of these disparate groups find that Rails provides sustainable relief for their pain. I don't know about you, but I find this quite remarkable!
At the moment, Ruby on Rails barely captures a tiny percentage of web development projects. Yet it is rapidly gaining mind share, and many respected software development leaders have been testing the waters with Rails and publicly singing its praises.
Perhaps it's time that you too checked out Rails to see firsthand what the fuss is all about.
Acknowledgments
Most of the sample source code shown in this article came from the Rails API documentation, with permission.
Resources
- Official Ruby home page
- Official Ruby on Rails home page
- Ruby on Rails documentation
- Instant Rails, a one-stop Rails runtime solution containing Ruby, Rails, Apache, and MySQL, all preconfigured and ready to run. There's no installer; you simply drop it into the directory of your choice and run it. It does not modify your system environment.
- The Locomotive project is a quick start to Ruby on Rails development on Mac OS X, providing a sandboxed, no configuration, one-folder install of Ruby on Rails, SQLite, Lighttpd/Fastcgi, and much, much more.
- Rails mailing list
- Ruby-talk mailing list
- Agile Web Development with Rails
- Rolling with Ruby on Rails (Part 1 and Part 2)
- Ajax on Rails
Curt Hibbs has been a consultant to well-known companies like Hewlett Packard, Intuit, Corel, WordStar, Charles Schwab, Vivendi Universal, and more. He now works as a Senior Software Engineer for The Boeing Company in St. Louis.
Return to ONLamp.com.
-
about it's productivity
2008-01-19 07:56:07 OrbanBotond [View]
-
Great deal on hosting
2005-10-28 11:49:13 abnerDesign [View]
-
Ruby on Rails is only one option
2005-10-26 11:30:03 teejay [View]
-
Ruby on Rails is only one option
2005-10-26 11:45:47 Curt Hibbs |
[View]
-
Ruby on Rails is only one option
2005-10-27 01:33:34 teejay [View]
-
Ruby on Rails is only one option
2005-10-27 04:07:09 Curt Hibbs |
[View]
-
Ruby on Rails is only one option
2005-10-27 05:32:20 teejay [View]
-
Ruby on Rails is only one option
2005-10-27 06:18:36 Curt Hibbs |
[View]
-
Ruby on Rails is only one option
2005-10-27 07:51:08 teejay [View]
-
Ruby on Rails is only one option
2005-10-27 08:14:53 Curt Hibbs |
[View]
-
Ruby on Rails is only one option
2005-10-27 01:47:20 teejay [View]
-
Ruby on Rails is only one option
2005-10-26 11:48:11 Curt Hibbs |
[View]
- Trackback from http://blogger.xs4all.nl/ipenburg/archive/2005/10/23/64283.aspx
re: Ruby on Rails, and other Open Source frameworks
2005-10-23 13:24:13 [View]
- Trackback from http://www.redev.org/archives/000080.cfm
Good Ruby Intro ...
2005-10-19 02:07:54 [View]
-
seaside web framework
2005-10-18 15:11:33 martin schubert [View]
- Trackback from http://www.ketema.net/serendipity/index.php?/archives/22-Ruby-On-Rails.html
Ruby On Rails
2005-10-18 08:26:47 [View]
- Trackback from http://nuhuati.zoomblog.com/archivo/2005/10/17/que-es-Ruby-on-Rails.html
¿Qué es Ruby on Rails?
2005-10-16 22:58:46 [View]
- Trackback from http://betweengo.com/?p=38
What Is Ruby on Rails
2005-10-16 04:51:28 [View]
-
Quick Start with Ruby on Rails on Mac OS X
2005-10-15 21:36:53 raaum [View]
- Trackback from http://weblog.freeopinion.org/articles/2005/10/15/curt-hibbs-has-outdone-himself
Curt Hibbs has Outdone Himself
2005-10-15 13:54:59 [View]
- Trackback from http://brilliantcorners.org/post/46
Good roundup of Ruby on Rails
2005-10-15 09:47:52 [View]
- Trackback from http://www.viamentis.com/node/24
O'Reilly publishes "What is Ruby on Rails?"
2005-10-14 23:28:55 [View]
- Trackback from http://ectio.us/node/6563
What Is Ruby on Rails
2005-10-14 15:24:01 [View]
- Trackback from http://www.lifehacker.com/software/programming/intro-to-ruby-on-rails-131138.php
Intro To Ruby on Rails
2005-10-14 15:03:22 [View]
- Trackback from http://www.lifehacker.com/software/programming/intro-to-ruby-on-rails-131138.php
Intro To Ruby on Rails
2005-10-14 13:05:05 [View]
-
WebObjects?
2005-10-14 11:46:10 DanD. [View]
-
Ruby on Rails vs TurboGears
2005-10-14 11:43:04 pierrebai [View]
-
Ruby on Rails vs TurboGears
2006-01-17 10:50:15 ramdaz [View]
-
Ruby on Rails vs TurboGears
2006-01-17 11:12:02 Curt Hibbs |
[View]
- Trackback from http://blog.case.edu/jms18/2005/10/14/what_is_ruby_on_rails
What is Ruby on Rails
2005-10-14 10:36:31 [View]
- Trackback from http://par-dev-portal1/CS/blogs/renes_blog/archive/2005/10/14/503.aspx
Can't Whistle? Check out Ruby On Rails!
2005-10-14 10:12:41 [View]
- Trackback from http://chipcuccio.us/2005/10/14/what-is-ruby-on-rails/
What is Ruby on Rails
2005-10-14 09:00:11 [View]
- Trackback from http://postdb.ricshreves.net/archives/171-Ruby-Baby!.html
Ruby Baby!
2005-10-14 07:33:31 [View]
-
that's cool
2005-10-13 21:30:11 errorter [View]
-
Very nice!
2005-10-13 17:28:20 Robby Russell |
[View]
-
Great article but....
2005-10-13 17:08:59 Oyku [View]