Rails, like many communities, has developed its own language. You need to know a lot of that language to understand what other people are saying, even when those people are trying to be helpful. This glossary gives you a quick guide to some common terms used in Rails that aren’t obvious to outsiders and provides the extra Rails meanings for words used elsewhere that have acquired additional meaning in Rails. Hopefully this will make it easier for you to understand Rails documentation and conversation, but of course, new terms will emerge over time:
The company where Rails was born, emerging from their Basecamp product.
Atomicity, Consistency, Isolation, Durability. A set of principles, usually implemented with relational databases and transactions, that are intended to ensure data reliability. Rails is not designed with ACID as a priority, though transactions are available as a plug-in. (In a different meaning, there are also a variety of “Acid” tests for CSS implementation conformance.)
The part of the Rails library that directly interacts with incoming HTTP requests, including routing, parameter passing, session management, and deciding how to render a response. Controller objects are the main way in which Rails developers interact with ActionController.
The part of the Rails library that manages incoming and outgoing email.
The combination of ActionController and ActionView, which provides a complete package for dealing with and responding to HTTP requests.
The part of the Rails library that generates responses to HTTP requests, based on information received from ActionController.
The Rails library that handles mappings between the database and Ruby classes. ActiveRecord is pretty much the foundation of Rails, but it can be used outside of Rails as well.
A collection of classes that were developed for Rails, but that can be used in any Ruby environment.
A common naming convention used in Rails, typically with plug-ins, to indicate that part of a model operates using code provided elsewhere.
Code, usually Ruby or Ruby and other languages, that connects ActiveRecord to a specific database.
Often used to describe collecting RSS or Atom syndication feeds, but has another meaning in Rails.
Aggregation lets you create simpler ways to access combinations of
data using the composed_of
method. You might do this to combine first and last names, or
address parts, or other pieces that can be broken down but that
are often conveniently used together.
A variety of software development techniques that tend to focus on smaller-scale iterative development rather than on top-down “waterfall” design and implementation.
Originally Asynchronous JavaScript and XML, this former acronym now refers more broadly to web development where methods within a page call back to the server and make smaller changes to a page rather than calling for a complete refresh every time. Ajax applications often resemble desktop applications more closely because of this added flexibility.
In Rails parlance, assets are information outside of your application and its database—images are a classic example—that are incorporated by reference. Assets don’t need to be entirely outside of the application, however. Chapter 8 shows how to have Rails manage the arrival of image assets.
An XML-based format originally used for syndicating information from blogs, but now moving into many applications where data needs to flow from site to site.
Attributes are information about an ActiveRecord model class, such as what fields it contains, what types they hold, and so on. Usually, Rails figures out what the attributes are directly from the application database, which knows what they are because they were set by migrations.
The process of making sure that a user (or other process) has the privileges they claim to have. Usernames and passwords are classic authentication mechanisms, but many others are possible.
A collaboration tool (http://www.basecamphq.com/) developed by 37signals and DHH. DHH realized while building Basecamp that the underlying framework could be reused for a lot of other projects, and that became the foundation of Rails.
Code used to determine and compare performance. Generic benchmarks used to test things like CPU performance are the most common usage, but you could create your own benchmarks to test performance specific to your application.
Chunks of code that can be passed among Ruby methods. Rails uses blocks to implement much of its view functionality, using this technique to connect code from different files into a coherent program.
Logic that is specific to a given application, and often specific to a given business. They specify rules for data that go beyond the computer-specific “This variable must be a string” to more complex rules like, “This date must be no earlier than x and no later than y” or “All expense reports must come with explicit and authenticated approval before consideration for payment.”
Rails does not do CamelCase, except in class names. CamelCase uses uppercase letters to identify
the beginnings of new words. Rails more typically keeps everything
lowercase, using underscores (_
) to separate the words.
A Ruby tool for automating running scripts on remote computers, typically used to deploy Rails applications and their updates.
A collection of methods and properties that together provide a definition for the behavior of objects.
A bad idea that disappeared in Rails 2.0, becoming a plug-in. Components mixed rendering and controller logic, and created applications that were both messy and slow.
A command-line interface to Rails applications, which is accessible through script/console
(also see
irb).
In HTTP requests (and network requests generally), content types are used to identify the kind of content being sent. Content types are often called MIME types, from their original development as Multipurpose Internet Main Extensions.
The switchboard for Rails applications, controllers connect information coming in from requests to appropriate data models and develop response data that is then presented through views.
A small (typically less than 4 kilobytes) chunk of text that is stored in a user’s browser and sent to the server that created it along with requests. Cookies can be used to track users across multiple requests, making it much simpler to maintain state across requests. In general, however, you should never store any significant information in cookies.
A Unix approach to scheduling tasks that need to run on a regular basis. “Cron jobs” are managed through the crontab configuration file, and the cron daemon makes sure they get executed as requested. (Rails itself doesn’t use cron, but you could use cron to manage periodic background housekeeping on a server, for instance.)
Create, Retrieve, Update, and Delete (sometimes Destroy). The basic functions needed by most data manipulation programs. SQL is very CRUD-like, as is REST.
Cascading Style Sheets, a vocabulary for specifying how precisely web pages should be displayed on screen, in print, or in other media. In a Rails application, a CSS stylesheet is typically an extra file or files kept in the public/stylesheets directory, referenced from each view that uses it.
Comma-separated values, a common if basic method for sharing tabular data.
Not the American pharmacy/convenience store, but the Concurrent Versioning System, used to manage different versions of programs and related files. In Rails, CVS has typically been replaced by Subversion or Git.
An HTTP verb that means what it says—to delete the resource the DELETE request is addressed to.
Putting something out in the “real world,” typically moving an application from development to operation.
The mode in which you’ll most likely modify and create code. In Rails, development uses a different database and settings from the test or production modes.
David Heinemeier Hansson, the creator of Rails and its lead developer. For more DHH, see his blog, http://www.loudthinking.com/.
Document Object Model, the standard API for manipulating HTML documents in a web browser. (It’s also used for XML and HTML outside of the browser.)
Don’t Repeat Yourself—a central principle of Rails development.
“If it walks like a duck and quacks like a duck, it’s a duck.” A way of determining what type an object has by looking at what it contains and how it behaves, rather than by looking for an explicit label on it. Duck typing is built into the Ruby language.
Automatically generated HTML that would let you tinker with a model and the underlying data without actually creating any views. Discontinued in Rails 2.0 in favor of static scaffolding.
See duck typing, described earlier.
The latest and (sometimes) greatest version of Rails, Edge Rails lets you develop with the most recent updates to the framework. Exciting for advanced developers, but potentially explosive for beginners. (Note that you can freeze Rails versions if one goes by that you really liked or, worse, a new one appeared that broke your code.)
Embedded Ruby, the syntax used for Rails views and layouts. ERb lets you mix HTML (or other text-based formats) with Ruby code.
An implementation of ERb that is both faster and offers several extensions to ERb. For more information, see http://www.kuwata-lab.com/erubis/. You can use Erubis with or without Rails.
A signal sent by a method call as it terminates (using raise
) to
indicate that things didn’t go correctly. You can deal with
exceptions using rescue
.
Controller code that lets you wrap your actions with other code that will get run before, after, or around your actions’ code.
A Firefox plug-in for debugging JavaScript and a wide variety of other aspects of web development.
Data created for the explicit purpose of using it to test your Rails applications. Fixtures are specified in YAML and provide a customizable set of data you can use to check the functionality of your Rails code. They are stored in the test/fixtures directory.
While you can include Adobe Flash content as external assets in your Rails
application, flash
in a Rails
context more frequently refers to a method for passing objects
between actions. You can set a message in the controller using
flash
and then retrieve and
display that message in a view, for example.
A class containing methods for creating HTML forms. Form builders are typically used to create consistent-looking interfaces across an application and to present complex aspects of your models that need additional interface support.
Pieces of views that you’ve asked Rails to cache so that they will be available on subsequent requests.
Locking your Rails application down so that it runs on a particular version of Rails, no matter what version of Rails you install on your computer more generally. For production applications, this provides a much more reliable running environment. You freeze and unfreeze through the Rake tool.
A package for a Ruby program or library that makes it easy to install across systems. Rails is distributed as a gem.
Generate, or script/generate
as it is called from the command line, is a program you can use to
have Rails create a wide variety of different types of code for
you. In general, when creating new functionality, you should let
Rails generate much of the code and then customize it, rather than
writing from scratch.
The most commonly used HTML request, which has the general meaning of “retrieve content from the specified URL.” GET requests are supposed to be idempotent and, despite the availability of query parameters, should not be used to change information in an application.
An application for sharing code and code development across many computers and developers. Ruby on Rails itself is now developed using Git to store and manage the code.
A commonly used method for escaping potentially dangerous content, removing HTML content that could create security problems.
An unordered collection of name-value pairs. You can retrieve the values by asking for them by name. (You need to know the name to do that, of course!)
An HTTP verb that is very similar to GET, but that only retrieves the headers, not the body of the request.
Provides support for commonly performed operations in view code. Helpers are a little less formal than form builders, which typically have more understanding of the context in which they work. Rails provides a wide variety of helper methods for common tasks like generating HTML, and you can add your own helper methods as well.
HyperText Markup Language, a common language used to present information over the web. HTML files define web pages, including content, formatting, scripts, and references to external resources.
HyperText Transfer Protocol, along with HTML, is the foundation on which the Web is built. HTTP supports requests that include a verb (like GET, POST, PUT, or DELETE) along with a variety of supporting information. Those requests are then answered by a responding server, which reports a [Response Code] and hopefully some information useful to whoever initiated the request. HTTP is itself built on top of TCP/IP, typically using port 80 to receive requests.
Like HTTP, but encrypted. Technically, the HyperText Transfer Protocol over Secure Socket Layer. HTTPS works much like HTTP, except that the web server adds a layer of encryption using public key certificates, it runs on port 443, and browsers are typically much more cautious about caching information that arrived over HTTPS.
An identifying value. In Rails, usually the primary key from a table of data, used for quick access to a particular row or object. In HTML, a unique identifier for one element in a document, often used for styling.
A fancy word for a specific meaning of reliable. If an action is idempotent, you can perform that action repeatedly without changing the result.
A command-line shell prompt for interacting with Ruby directly, irb lets you try out code in a much simpler environment than Rails.
Internet Relay Chat, a key part of the communications that hold the Rails community together. You can find a lot more information on Rails and IRC, including servers, channels, and clients, at http://wiki.rubyonrails.org/rails/pages/IRC.
A method that loops through a set of objects, working on each object in the set once.
JavaScript Object Notation, a text-based format for exchanging objects. Douglas Crockford “discovered” it already existing inside of JavaScript and made it a popular interchange format. It’s often seen as a more programming-oriented complement or competitor to XML. (It’s also a subset of YAML.)
A file containing the beginning and end of the HTML documents to be returned by views, allowing views to focus on the content of documents rather than on the headers and foots.
Mac OS X 10.5, notable mostly for improvements to its Ruby support, which make it much easier to use and update Rails. (Rails comes preinstalled now, though in an old version.)
A new web server designed to be smaller and more efficient than Apache. If you want to run Rails through FastCGI, lighttpd is a good option.
Rails supports traditional HTML linking, but in many cases you’ll want to use a helper method to create links between the components in your applications.
Yukihiro Matsumoto, creator and maintainer of the Ruby language. “Matz is nice, and so we are nice” (MINASWAN) is a key principle of Ruby culture.
Originally “Mongrel plus ERb,” Merb is a Ruby-based MVC framework that is not Rails.
Instructions for changing a database to add or remove structures that Rails will access. The Rake tool is used to apply or roll back migrations.
A technique for testing Rails applications that creates objects that expect particular methods to be called, and that exposes more information on the objects for easier debugging.
See Passenger.
Code that handles the interactions between Rails and a database. Models contain data validation code—code that combines or fragments information to meet user or database expectations—and pretty much anything else you need to say about the data itself. However, models do not contain information about the actual structure or schema of the data they manage—that is kept in the database itself, managed by migrations.
A Ruby-based web server now used as the default server for Rails applications when run from the command line. In production, a “pack of mongrels” often runs behind an Apache web server, connecting HTTP requests to Rails.
Model-View-Controller, an architecture for building interactive applications that lies at the heart of the Rails framework. (See Chapter 3 for a lot more information.)
A popular open source relational database, commonly used to store data for larger Rails applications.
The glue that holds Rails together, letting applications figure out which pieces connect to which pieces without requiring a formal mapping table. Rails makes naming conventions feel more natural by supporting features like pluralization.
A value that means “no value.” Nil also evaluates to false
in
comparisons.
An instance of a class, combining the logic from the methods of the class with properties specific to that particular object.
Object-Relational Mapping, the hard part of getting object-oriented languages and relational databases to work together. Rails addresses this using ActiveRecord and makes it (mostly) transparent through naming conventions.
Chopping up long lists of data into smaller, more digestible chunks. In Rails 2.0, pagination moved
out from the core framework into plug-ins, most notably will_paginate
.
A piece of view code designed to produce part of a
document. Multiple views can then reference the
partial so that they don’t have to repeat the logic it already
contains. Partial names are prefixed with _
.
An Apache module, also called mod_rails, for deploying Rails applications behind an Apache web server.
Programming Ruby, the first major book on Ruby, published by the Pragmatic Programmers. Its third edition covers Ruby 1.9.
Additional code, often packaged as a gem, that you can use to provide additional functionality to Rails.
A feature of ActiveRecord that generates much controversy. Models have singular names, like person, while views and controllers use plurals of those names, because they work with many instances of the models. Rails has a set of defaults that handle both standard English pluralization and some common irregulars, like person and people, child and children. There are cases where pluralization doesn’t work in English, but fortunately they rarely affect programming.
An HTTP method that sends information to a given URI. POST is mapped to CREATE in REST-based Rails applications, though POST has been used as a general “send-this-stuff-over-there-via-HTTP” method in the past.
A more powerful but somewhat more daunting open source database that is frequently used by developers who want more control than MySQL provides, or access to specific extensions, like the geographic data work in PostGIS.
A proxying load balancer designed to pass HTTP requests from a web server to other servers in the background.
The Pragmatic Programmers, Dave Thomas and Andy Hunt, and their publishing company (http://www.pragprog.com/). They’ve written and published a wide variety of books on Ruby and Rails, and run related training courses.
Private methods and properties appear in Ruby classes after the private
keyword, and are only accessible
to other code in that same class.
A basic JavaScript library for Ajax development that reduces the amount of redundant code needed to build an application.
Proxy servers (or proxies) receive requests on one end and then resubmit them to other servers. Proxies can be used to manage performance, to provide caching, to hide servers from users (and vice versa), for filtering, or for pretty much anything you want to do with an HTTP request between the request and the response.
An HTTP method used to send a file to a URI. In Rails RESTful routing, PUT maps to UPDATE, replacing content that was previously there with new content.
A technique used by several browsers to support web pages formatted with older (broken) browsers in mind, while still allowing developers to specify that their pages should be processed using newer and generally more correct standards.
A conference focused on Rails, usually once a year in North America and once a year in Europe. For more information, see http://railsconf.com/.
A command-line tool that originally was Ruby’s replacement for the make build tool commonly used by Unix applications. Thanks to its scriptable extensibility, it has turned into a one-stop toolkit for applying migrations to databases, checking up on routes, freezing and unfreezing the version of Rails used by a given application, and many more tasks.
The documentation generator used by most Ruby applications, including Rails. The Rails API documentation all gets built through RDoc.
Responding to a request to one URI by telling the requester to visit a different URI.
Regular expression, a compact if sometimes inscrutable means of describing patterns to match against targeted text.
To convert data from one form to another, usually to present it. Web browsers render HTML into readable pages, while Rails views render data from Rails into HTML that gets sent to users’ web browsers.
In HTTP, a request is a message sent from a client to a server, identifying a resource (a URI) and providing a method—usually GET, PUT, POST, or DELETE.
For Rails development purposes, it’s probably easiest to think of a resource as code identified by a URI (or URL). It’s the code that will get called once Rails routing has examined the request and decided where to send it. (Outside of Rails, it can be a deeply philosophical notion at the heart of web architecture and infinite debates about web architecture.)
In HTTP, a response is a message sent from a server to a client in response to a request. It generally includes a status code as well as headers describing the kind of response, and data to present the client.
Not a vacation. Technically, “Representational State Transfer,” but really just a sane way to handle interactions on the Web in a way that takes full advantage of the underlying web architecture instead of chucking it and building something entirely different. Rails 2.0 includes a lot of features designed to make building REST-based applications easier. (See Chapter 5 for a lot more detail.)
A kind of Rails template used to generate JavaScript, typically for Ajax applications.
A gem that lets Ruby applications manipulate graphics using the ImageMagick library.
To send from one place to another. In Rails, the routing code examines requests coming to the server from various clients and decides based on their URIs which controller should respond to them.
An acronym of various meanings that refers to several different XML formats for syndicating information from one site (typically weblogs, but also newspapers, periodicals, and others of sites) to clients and other servers that might be interested.
A site (http://rubyforge.org) that hosts a wide variety of open source Ruby software projects in development. You can use it as a place to share code you write or to find code others have already created.
Code that gets you started, much as scaffolding on
a construction project lets workers get to the parts
of a building they need to modify. Rails can
generate scaffolding code for a wide variety
of different project needs, though in Rails 2.0 scaffolding most frequently refers
to the REST-based set of models, views, and controllers created by script/generate scaffold
.
Scale reflects size. If a program scales, it can survive growing rapidly from serving only a few simultaneous users to serving thousands or even millions of users.
A JavaScript library, built on top of Prototype, for creating Ajax applications and effects, often used in Rails-based Ajax development.
A series of HTTP interactions between a single client and the web server. Sessions are usually tracked with cookies or with explicit logins.
An object that has only one instance in a given application. You shouldn’t (and generally can’t) create more than one of it.
Originally the Simple Object Access Protocol, it proved not very simple, not necessarily bound to objects, and not exactly a protocol. SOAP is the foundation of most web services applications that don’t use REST, taking a very different approach to communications between applications.
The Structured Query Language is a common foundation used by databases to create and destroy structures for holding data, and to place and retrieve data inside of them. While SQL is extremely useful, Rails actually hides most SQL interactions so that developers can work with Ruby objects only, rather than having to think in both Ruby and SQL.
A simple database that stores its information in a single file. (In Rails, that file is kept in the db directory.) SQLite is extremely convenient for initial development, but slows down dramatically as the number of users grows.
A program used to manage different versions of programs and related files across many computers and developers. Many developers building Rails applications use Subversion, but the Rails code itself is now managed in Git.
Ruby identifiers prefaced with colons that Rails uses for pretty much every variable that gets passed from model to view to controller, as well as for named parameters. Symbols look and behave like variables for most ordinary programming purposes, but they give Rails tremendous flexibility.
Templates are files used to generate output. In Rails, views are written as templates, typically ERb or Builder templates, though a variety of other template formats are available as extensions.
Code designed to put a particular application piece through its paces. Rails comes complete with support for creating your own unit tests (does a model behave predictably?), functional tests (does a method do what it should?), integration tests (do these methods work together?). You can also create performance tests (how fast does this go, anyway?), and use stubs and mock objects to isolate components for testing.
If you came to Rails from Java or a similar language, you may be looking around for threads. Ruby has threads after all—why doesn’t Rails? Well, Rails is single-threaded, handling requests in a single thread. There are lots of ways around this, including having multiple instances of Rails servers all accessing the same database.
Mac OS X 10.4, notable mostly for including an old version of Ruby that made it hard to install and use Rails.
Universal Description, Discovery, and Integration, a supposedly magical but now largely forgotten piece of the web services picture. It was designed to help developers and programmers find SOAP-based web services.
The industry-standard way to identify characters. Originally, Unicode mapped one character to each of 65,535 bytes, but as that space filled, it became clear that things were more complicated. Ruby’s Unicode support improved substantially in version 1.9, but most things will work fine in 1.8.6.
Uniform Resource Identifier, a slightly polished up and abstracted version of the old URL that can be used to identify all kinds of things, no longer bound to a few protocols. In REST-based Rails applications, URIs connect to applications in a generally unsurprising way.
Uniform Resource Locator, the identifers that hold together the web. URLs specify a scheme (like http, ftp, or mailto) that maps to a particular protocol, and the rest of the URL provides information that, used with software supporting the scheme, gets you to the information the URL points to. (Or, if the information is gone, an error message.)
Coordinated Universal Time, formerly known as Greenwich Mean Time (GMT) or Zulu Time. Time zones are generally expressed as offsets from UTC. (UTC is a “compromise abbreviation” between English and French.)
A common encoding for Unicode characters. Old ASCII files are naturally UTF-8 compliant, but characters outside the ASCII range are encoded into multibyte representations. UTF-16 uses two bytes for most commonly used Unicode characters (on the Basic Multilingual Plane) and encodes characters outside of that range into multibyte sequences.
Checking that something is what it’s supposed to be. In Rails, data validation should be performed in the model, though some checks may also be performed in view code—for example, in Ajax applications that do as much on the client as possible.
The aspect of a Rails program that presents data and opportunities for interaction to users, whether those are users of web browsers getting HTML or other programs using XML or JSON or something else entirely.
What happens when the world finally “gets” the Web instead of treating it as a place to present brochures and catalogs, recognizing that the interactions among millions of people are creating new and (often) useful things.
A generic term for people who build applications or sites for the Web. Also, a Firefox plug-in that makes it easy to inspect various aspects of client-side website functionality as well as turn them on or off.
Using the Web for program-to-program communication, rather than the classic model of a human at a web browser interacting with a server. Web services development has largely bifurcated into SOAP-based (or WS-*) development and REST development. Rails 2.0 took a decisive shift toward REST, though you can still write SOAP web services in Rails if you want to.
A Ruby-based web server that is built into standard Ruby distributions since version 1.8.0. Recent releases of Rails typically use Mongrel instead.
Author of “Why’s Poignant Guide to Ruby” (http://poignantguide.net/ruby/), and much more at http://whytheluckystiff.net/.
The Web Services Description Language, used most frequently by SOAP-based (or WS-*) web service developers, provides a way of describing a web service that programs and humans can use to develop code for interacting with it.
Extensible HTML—basically HTML with XML syntax. If you’re doing a lot of Ajax work, using XHTML can simplify some of your debugging, but it hasn’t exactly caught the world on fire.
Extensible Markup Language is a widely used format for storing information. It insists on precise syntax, but can support a very wide and customizable set of data structures.
A JavaScript method that lets a program running in a web browser communicate with the server
that delivered the page, using the full set of verbs in the HTTP
protocol. It is supported by all of the major graphical web
browsers, though implementation details are only recently becoming
consistent across implementations. XMLHttpRequest
is at the heart of
Ajax development.
An early web services protocol that let developers make remote procedure calls using a particular (and very verbose) XML vocabulary sent over HTTP requests.
Cross-site scripting is a security hazard that allows
crackers to interfere with your program’s logic by
inserting their own logic into your HTML. The main means of
ensuring that your applications don’t encounter it is to treat
content that might have originated from outside of your immediate
control as hostile, accepting as little HTML as your application’s
needs can tolerate. The h
method makes it generally easy to escape any HTML that does come
through.
Yet Another Markup Language, YAML was originally developed as a more programming-centric alternative to XML. Ruby supports YAML for object persistence. Rails uses YAML for configuration information. (And as it turns out, largely by coincidence, JSON is a subset of YAML.)
A sometimes mind-boggling Ruby feature that lets methods take a block of code along with the rest of
their parameters and then call that code with yield
when needed. Among other things,
this is how Rails implements the relationship between views and
layouts.