<?xml version="1.0" encoding="UTF-8"?>
<article-node>
  <account-id type="integer">2</account-id>
  <author>Michael Slater</author>
  <aux>If you&amp;#8217;re new to Ruby on Rails, you may be struggling to understand just what Rails is, what it can do for you, and what you need to learn to use it effectively. In this article, we&amp;#8217;ll explain just that.</aux>
  <body>&lt;p&gt;If you&amp;#8217;re new to Ruby on Rails, you may be struggling to understand just what Rails is, what it can do for you, and what you need to learn to use it effectively. In this article, we&amp;#8217;ll take a quick romp through the various aspects of Rails. We&amp;#8217;ve sprinkled links liberally, so you can use it as an annotated table of contents for the rest of the site.&lt;/p&gt;
&lt;h2&gt;What is Ruby on Rails?&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;/topic/show/5-ruby-on-rails&quot;&gt;Ruby on Rails&lt;/a&gt; encompasses a number of technologies, and some philosophy as well. This can make it challenging to get your arms around just what Ruby on Rails is.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;/topic/show/6-ruby&quot;&gt;Ruby&lt;/a&gt;&lt;/strong&gt; is a programming language. By itself, there&amp;#8217;s nothing about Ruby that is specific to web applications.&lt;/p&gt;
&lt;p&gt;Ruby is a modern, object-oriented, dynamic language. In Ruby, everything is an object &amp;#8212; even a number is an object that has methods. Ruby is dynamic; data types are assigned dynamically, and you can extend the language itself as it is executing, defining classes, adding methods, and so forth.&lt;/p&gt;
&lt;p&gt;Ruby has a very clean, minimalist syntax. This, combined with its dynamic nature, makes it especially suitable for creating extensions to the language that enable your programs to read almost like English.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;/topic/show/5-ruby-on-rails&quot;&gt;Rails&lt;/a&gt;&lt;/strong&gt; is a framework for writing web applications in Ruby. The term &amp;#8220;Rails&amp;#8221; is commonly used to refer to &amp;#8220;Ruby on Rails,&amp;#8221; which is the official name of the framework.&lt;/p&gt;
&lt;h2&gt;Why Use Rails?&lt;/h2&gt;
&lt;p&gt;If the application you are building falls into the very large sweet spot for which Rails works well, there&amp;#8217;s no faster way to write it &amp;#8212; once you&amp;#8217;re up-to-speed on the framework. There&amp;#8217;s a sizable learning curve to comprehend the Rails framework, but once you have the basics of it down, you&amp;#8217;ll be able to produce robust, fully customized applications more quickly than with any other technology.&lt;/p&gt;
&lt;p&gt;Because the Rails approach eliminates a lot of the drudgery of writing applications in languages such as Java, and because it makes changes easy and allows you to write expressive, readable code that is easy to maintain, it is simply more fun to build Rails applications. When coding is more fun, you&amp;#8217;ll write better code.&lt;/p&gt;
&lt;p&gt;Because Rails requires less code than most other approaches, you can produce a given application with fewer people. Smaller teams are more efficient than larger ones, multiplying the productivity gains of using Rails.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s also a great Rails community, so there&amp;#8217;s lots of open-source plugins and even complete applications, plus countless blogs and other information sources. It&amp;#8217;s an enthusiastic, helpful, programmer-centric community that puts a high priority both on building great applications and on having fun while you&amp;#8217;re doing it.&lt;/p&gt;
&lt;h2&gt;When Not to Use Rails&lt;/h2&gt;
&lt;p&gt;Rails is not the answer to every problem. Here&amp;#8217;s a few situations in which it is probably not the best approach:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;If you&amp;#8217;re new to Rails but are already up-to-speed in another technology, and the app you&amp;#8217;re building isn&amp;#8217;t too large, you&amp;#8217;ll get the work done more quickly by sticking with what you know. This is the major factor that stops most developers from switching to Rails. If you&amp;#8217;re building a large application, or think longer term, however, working your way up the Rails learning curve is very worthwhile.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
	&lt;li&gt;If you can create the application using something like Joomla, in which you can do a lot without writing any code at all, that&amp;#8217;s probably the quickest approach. You loose a lot of flexibility, however.&lt;/li&gt;
	&lt;li&gt;If the application needs to perform tremendous amounts of computation, the relatively slow speed of Ruby may be a disadvantage. This is quite rare, however, and you can always move the inner loops into a language such as C.&lt;/li&gt;
	&lt;li&gt;If you expect to have extremely high traffic, your server costs may be higher with a Rails application, and you&amp;#8217;ll have to do more innovating beyond what the framework gives you automatically. Then again, the time you save building the application may still make it a worthwhile trade-off.&lt;/li&gt;
	&lt;li&gt;If you have to share a legacy database with existing code, so you can&amp;#8217;t restructure it, it may be hard to make Rails work with it.&lt;/li&gt;
	&lt;li&gt;If you&amp;#8217;re building a static site, Rails is probably overkill. Even so, the templating engine in Rails is very useful for such sites, the built-in caching features can eliminate the need to run the Rails code on most accesses, and you can easily build in your own content-management features. But it is more expensive to host Rails sites than static sites, and there&amp;#8217;s a lot more you need to understand to build them.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you can probably tell by now, we think Rails is a great solution for the vast majority of web applications.&lt;/p&gt;
&lt;h2&gt;The Rails Philosophy&lt;/h2&gt;
&lt;p&gt;Before we get into the specifics of what Rails is composed of, it is helpful to understand the philosophy that underlies its approach.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s two terms you&amp;#8217;ll hear a lot with regard to Rails: &amp;#8220;convention over configuration&amp;#8221; and &amp;quot;DRY (don&amp;#8217;t repeat yourself).&lt;/p&gt;
&lt;p&gt;Convention over configuration is a very important principle behind Rails. It goes hand-in-hand with another attribute of Rails, that it is &amp;#8220;opinionated software&amp;#8221;. The Rails design embodies lots of opinions about how you should structure your code, name your classes and files, and organize your database tables. There are methods to override most of these conventions, but if you go with the flow and follow the conventions, then you can avoid almost all configuration code. That&amp;#8217;s convention over configuration &amp;#8212; and the payoff is huge.&lt;/p&gt;
&lt;p&gt;Keeping your code &lt;span class=&quot;caps&quot;&gt;DRY&lt;/span&gt; means avoiding repetition. In its simplest form, it means that if you need the same code in two places, put it in a method so you can write it once and call if from both places. It sometimes increases the amount of work it takes to write your code initially, but it save headaches in the long run. There&amp;#8217;s various facilities in Rails to encourage this, but it is something you need to pay attention to when writing your code.&lt;/p&gt;
&lt;p&gt;In the past year or so, the Rails community has also leaned heavily toward &lt;a href=&quot;/topic/show/105-rest&quot;&gt;RESTful&lt;/a&gt; architecture. There&amp;#8217;s no requirement to use a &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; design, but Rails is increasingly encouraging you to do so, and providing tools to make it easier.&lt;/p&gt;
&lt;h2&gt;Aspects of Rails&lt;/h2&gt;
&lt;p&gt;Rails is designed to make it easy and fun to create interactive, reliable, database-backed web applications. Rails is a set of programming libraries, but it is more than that &amp;#8212; it is an approach to developing web applications. These are the major aspects of Rails:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Rails implements the &lt;a href=&quot;/topic/show/40-model-view-controller-mvc-architecture&quot;&gt;model-view-controller&lt;/a&gt; (&lt;span class=&quot;caps&quot;&gt;MVC&lt;/span&gt;) pattern for application design. Your application code is divided into models, which deal with the database and manage the data; views, which present present data to the user and allow the user to interact with the application; and controllers, which mediate between the two.&lt;/li&gt;
	&lt;li&gt;Rails provides base classes from which your &lt;a href=&quot;/topic/show/8-models&quot;&gt;model&lt;/a&gt; and &lt;a href=&quot;/topic/show/9-controllers&quot;&gt;controller&lt;/a&gt; classes inherit. This endows your classes with a great deal of capability without writing a single line of code beyond the class declaration.&lt;/li&gt;
	&lt;li&gt;Rails includes &lt;a href=&quot;/topic/show/73-active-record&quot;&gt;Active Record&lt;/a&gt;, a module that provides an Object Relational Model (&lt;span class=&quot;caps&quot;&gt;ORM&lt;/span&gt;) that automatically instantiates Ruby objects from your database tables. Your code never has to touch the database directly; it deals with Ruby objects, and ActiveRecord takes care of persisting those objects in the database.&lt;/li&gt;
	&lt;li&gt;Rails provides many classes and methods that facilitate common tasks in web applications, such as processing data from forms and validating data before writing it to the database.&lt;/li&gt;
	&lt;li&gt;Rails &lt;a href=&quot;/topic/show/10-views&quot;&gt;views&lt;/a&gt; are created by a templating system that automatically composites each web page from a &lt;a href=&quot;/topic/show/114-layouts&quot;&gt;layout&lt;/a&gt;, which typically provides the overall structure for the page, a template that defines the unique content of the page, and a special type of template, called a partial, for elements that are used in multiple places.&lt;/li&gt;
	&lt;li&gt;The Rails templating system allows you to mix &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; and Ruby code, and it provides a rich set of helpers to simplify the generation of &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; and JavaScript code. There&amp;#8217;s also a special type of template for producing &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt;.&lt;/li&gt;
	&lt;li&gt;There&amp;#8217;s also support for &lt;a href=&quot;/topic/show/85-caching&quot;&gt;caching&lt;/a&gt; pages and parts of pages to increase performance.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;/topic/show/91-rjs&quot;&gt;&lt;span class=&quot;caps&quot;&gt;RJS&lt;/span&gt;&lt;/a&gt; (Ruby JavaScript) templates allow you to write Ruby code that the Rails framework translates to JavaScript for execution in the browser. This is a powerful facility for easily creating sophisticated Ajax interactions.&lt;/li&gt;
	&lt;li&gt;Rails migrations enable you to define your database schema with Ruby code, and to easily migrate from one version of the schema to another.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;/topic/show/56-testing&quot;&gt;Testing&lt;/a&gt; is built into Rails, streamlining the process of writing and running automated tests for your application at various levels.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, as you can see, there&amp;#8217;s a lot to Rails. And there&amp;#8217;s more &amp;#8212; the Rails ecosystem includes a number of tools and extension methods:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Generators are special Rails methods that automate the creation of models, controllers, and so forth.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;/topic/show/79-scaffolds&quot;&gt;Scaffolds&lt;/a&gt; are a kind of generator that automates the creation of a basic set of integrated functionality. Most often this is used to support the Create/Read/Update/Delete (&lt;span class=&quot;caps&quot;&gt;CRUD&lt;/span&gt;) views and controller actions for a given model, but scaffolds are available for other features such as &lt;a href=&quot;/topic/show/105-rest&quot;&gt;RESTful&lt;/a&gt; interfaces.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;/topic/show/77-gems&quot;&gt;Gems&lt;/a&gt; are packages of Ruby code that are easily shared.&lt;/li&gt;
	&lt;li&gt;Rails &lt;a href=&quot;/topic/show/71-plugins&quot;&gt;plugins&lt;/a&gt; are like gems but are installed directly into a particular Rails application.&lt;/li&gt;
	&lt;li&gt;Two &lt;a href=&quot;/topic/show/34-javascript&quot;&gt;JavaScript&lt;/a&gt; frameworks are directly supported by Rails: &lt;a href=&quot;/topic/show/38-prototype&quot;&gt;Prototype&lt;/a&gt;, which extends the JavaScript language, abstracts away browser differences, and makes many common tasks simpler; and &lt;a href=&quot;/topic/show/39-scriptaculous&quot;&gt;Scriptaculous&lt;/a&gt;, which is a visual effects library.&lt;/li&gt;
	&lt;li&gt;RDoc and RI are Ruby tools for creating and viewing program documentation.&lt;/li&gt;
	&lt;li&gt;The Rails Console provides a command-line environment for interacting directly with your application.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;/topic/show/212-rake&quot;&gt;Rake&lt;/a&gt; is an automation tool for performing common tasks in developing Rails applications, such as migrating from one database schema version to another.&lt;/li&gt;
	&lt;li&gt;Capistrano is an automation tool for &lt;a href=&quot;/topic/show/44-rails-deployment&quot;&gt;deploying applications&lt;/a&gt;. It automates the process of publishing new versions to a production or staging server, and it also allows you to perform many server tasks without having to explicitly log in to the server and issue shell commands.&lt;/li&gt;
	&lt;li&gt;Mongrel is an application server that is widely used to run Rails applications. Typically an &lt;a href=&quot;/topic/show/90-http-servers&quot;&gt;&lt;span class=&quot;caps&quot;&gt;HTTP&lt;/span&gt; server&lt;/a&gt;, such as Apache or Nginx, serves up static content and cached pages, while requests that require Rails processing are sent to Mongrel.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Now What?&lt;/h2&gt;
&lt;p&gt;That wraps up our whirlwind tour of what Rails is and why it&amp;#8217;s worth learning. Follow the links in the article to learn more about each of the topics. And for an easy way to begin learning, sign up for our &lt;a href=&quot;/course&quot;&gt;free online course in Ruby on Rails&lt;/a&gt;.&lt;/p&gt;</body>
  <created-at type="datetime">2008-07-24T01:00:46-07:00</created-at>
  <created-by type="integer">1</created-by>
  <dy-schema-id type="integer" nil="true"></dy-schema-id>
  <dy-schema-type nil="true"></dy-schema-type>
  <filter-id nil="true"></filter-id>
  <flags type="integer">1</flags>
  <historic-id type="integer">7</historic-id>
  <id type="integer">6400</id>
  <kind-id type="integer">5019</kind-id>
  <lock-version type="integer">3</lock-version>
  <name>Understanding Ruby on Rails</name>
  <owner-id type="integer" nil="true"></owner-id>
  <owner-type nil="true"></owner-type>
  <published-at type="datetime">2008-04-22T17:00:00-07:00</published-at>
  <rating type="integer">3</rating>
  <ref-count type="integer">0</ref-count>
  <sequence type="integer">0</sequence>
  <status type="integer">0</status>
  <updated-at type="datetime">2009-03-23T22:59:57-07:00</updated-at>
  <updated-by type="integer">1</updated-by>
  <url nil="true"></url>
  <user-id type="integer">1</user-id>
  <version type="integer">4</version>
  <workflow-task-status-id type="integer" nil="true"></workflow-task-status-id>
</article-node>
