rubyonrails-talk List FAQ

This hasn't been kept up to date since mid-2008.

This was a list of frequently asked questions for the Ruby on Rails: Talk mailing list and Google Group. The group is devoted to discussion of the Ruby on Rails ("Rails") web application framework. This is the list FAQ, and not affiliated with the Ruby on Rails core team, nor with any of the book and blog authors mentioned in the FAQ. The FAQ is maintained by Faisal N. Jawdat, with contributions from the rubyonrails-talk list members. If you have additional questions or answers you'd like to include, please mail them to

General Questions

Technical Questions

General Questions

What is the difference between Ruby and Rails? [ruby-rails-difference]

Why should I use Ruby? [why-ruby]

If you are using Rails then you will need to use Ruby because Rails is written in and extensible using Ruby. If you have not yet decided to use Rails then you might elect to use a different web application framework based around a different language. These include MVC frameworks such as:

...and non-MVC tools such as:

Although Ruby has been getting a lot of attention due to Rails, Ruby predates Rails by almost 10 years and has been used for many scripting applications in that time. Many Ruby programmers prefer it over other languages because of its elegance. However, insofar as this list is devoted to the discussion of Rails, those arguments are rather irrelevant here.

What's good about Ruby? [why-ruby2]

Ruby is a powerful and expressive language. Ruby is a dynamically typed pure-OO language, and contains support for closures, continuations, and reflections. Most Rubyists find that they can write more compact code in Ruby than in other languages, and that the Ruby code is cleaner and easier to read and debug than in other languages. YMMV.

What is a good book about Rails? [what-book]

Many people on the list consider Agile Web Development with Rails ("AWDwR", Dave Thomas, et al.) to be "the book" on the subject. AWDwR is also available as a PDF directly from the publisher.

For a more introductory treatment, you may consider Ruby on Rails: Up and Running (Bruce Tate and Curt Hibbs).

True to its name, Ruby for Rails: Ruby Techniques for Rails Developers gives a more in depth coverage of the Ruby behind Rails, and how you can use it.

Can someone send me a PDF copy of AWDwR? [i-wish-to-violate-a-copyright-in-public]

Short answer: No.

Long answer: The PDF is available for purchase online, and that PDF comes personalized with the name of the buyer. In addition, many if not all of the contributors to the book are on this list. Further, these authors are liked and respected for their contributions to the community. Finally, publicly asking someone you don't know to violate a copyright in a publicly available archived list isn't going to win you any friends here. Don't even ask.

Are there any good online references? [online-references]


Is there a good editor for Rails? [good-editor]

In general, any programmer-friendly text editor should work, particularly any editor with support for Ruby and HTML, which is most of them.

Does Rails do AJAX? [ajax]

Yes. Rails includes:

Rails AJAX development is trending towards pushing as much of the AJAX logic as possible into Ruby code so the programmer needs to go outside Ruby as little as possible. YMMV.

Mail seems out of order. How can we fix it? [list-reliability]

The list uses Google Groups, which is occasionally unreliable. In general, the mail comes through eventually. So far this hasn't been a problem.

Why is all this spam coming through? [spam]

Google Groups does not have 100% effective spam prevention mechanisms. The list maintainers attempt to remove spam from the online archive -- and remove the spammers from the list -- as spam is noticed, but this, too, is not 100% effective. You may wish to look into getting a spam filter for your client.

Is there a Ruby or Rails group in ...? [israel]

Probably: Israel, Silicon Valley, Washington, DC, etc. The UserGroups in Ruby on Rails list on the Wiki is probably the first place to check (although it can get out of date).

Technical Questions

How do I install Rails? [install]

See the core site's instructions here.

How can I create a self-referential has_many :through association? [self-referrential-has-many]

See Josh Susser's description here.

Why do I need to write all these tests? [why-test]

You don't need to, but it's probably a good idea if you want your code to actually work. There is a technical answer and a philosophical reasons to test with Ruby (and, by implication, Rails).

The technical answer is that Ruby, like all dynamic languages, does more at runtime and less at compile time. Accordingly, the compiler won't catch a lot of the sorts of things that Java and C#'s compilers would. However, a test suite that exercises much of your code will tend to catch those problems.

The philosophical answer is that the Rails community tends to favor Agile methods of software development, and Agile methods tend to favor test-heavy (often test-first or test driven) programming practices due to their flexibility.

In any case, Rails comes with a built in testing framework, and Rails developers tend to use the framework heavily.

How do I get a Rails app to start at startup on a Mac OS X system? [osx-startup]

The answer to this depends on what platform you're using to deploy Rails. For most things, you'll need to use launchd, or a StartupItem. launchd is Apple's prefered method, and StartupItems are going away, although StartupItems are often a better fit for many UNIX daemons.

However, if you're using the built-in Apache 1.3 setup with fcgi, you can just start Apache from the Sharing pane in System Preferences.

Where can I host Rails apps [hosting]

Anywhere you have total control of your host. In addition, many hosting providers are starting to provide Rails support. That said, running Rails in production can be tricky, and hosting providers are still developing competency in this area. Further, the environment they offer may be out of sync with the version of Rails that you require. There is no simple answer here, and it pays to do your homework before spending money.

How should I set up web servers for running in production? [deploying-www]

The answer to this question is still open, and your answer will depend in large part with what server software you are required to use, what performance constraints you have, and how much tolerance you have for bleeding-edge code. As of summery, 2007 it appears the favored setup involves one or more instances of Apache with modproxycore, or a load-balancing proxy server, speaking to multiple (possibly distributed) instances of Mongrel running Rails.

How can I best deploy releases of my app? [deploying-cap]

Use Capistrano

Ruby is slow! (Ruby uses a lot of memory, Rails is not threaded, etc.) [ruby-performance]

(Yes, that wasn't a question, but the topic comes up enough to merit an entry.)

Ruby is slower than many other programming languages for similar applications, both in general (more instructions and resources required to get the same work done) and specific (non-native threads, etc.) That said, many Rubyists find that the cost in execution speed is made up for in programmer happiness and productivity, and that these improvements make it easier for Ruby programmers to optimize their code more effectively. A couple projects exist to speed up the Ruby interpreter, but they're a few years out at best.

Ruby's performance is less of an issue for Rails. Rails deployment is typically fairly distributed, and the main performance bottleneck is usually somewhere other than Ruby itself (e.g. database load). Rails developers typically uses approaches like Memcached to boost real-world performance where needed. Understanding where the bottlenecks live is important.

How many users/requests/sessions can [some config] handle? [load]

This is impossible to answer without testing the exact config with behavior closely resembling that of real users and your real application's real code. While list members may throw out some ballpark numbers, their answers depend on their configs and thus should be treated with skepticism.

How do I test an action that requires a user to be logged in? [authenticated-testing]

It depends on how you're doing authentication. If you're using actsasauthenticated, then include AuthenticatedTestHelper and login_as :user_name_here. If you're using some other method then you'll need to somehow fake out the system (e.g. manually populate the session). See this thread for more.

What does this Ruby code mean? [code-idioms]

method? : Method names ending with a question mark indicate a method which returns a boolean response. For example, nil? returns true if the object is nil (or does not exist), or false otherwise. This is a naming convention and is not enforced by the language.

method! : Method names ending with an exclamation point indicate a destructive method. As with boolean questions, this is a naming convention and is not enforced by the language.

:symbol : A string starting with a colon is a Ruby symbol. Symbols are tokens used for user-level constructs in Ruby, e.g. hash keys, method flags, etc. For more detail, see here.

foo ? bar : baz : This is a ternary operator (and may be familiar to Java and C users). If foo is an expression and bar and baz are (or return) values, then this is a conditional expression. The expression returns bar if foo is true, or baz if foo is false. Note that you must have spaces between each of the elements or Ruby will interpret the punctuation as parts of the identifiers they touch.

How do I enforce foreign key constraints in the db? [foreign-keys]

Rails does not have built in support, but you can add the constraint manually in a migration using the execute statement. RedHill Consulting has also created two plugins to add support FK constraints to Rails.

How do I test views? view helpers? migrations? [more-testing]

To test views you will need to use assert_select. AWDwR has more documentation on the method, and Assaf Arkin put together a useful cheat sheet on the method. To test helpers, use Geoffrey Grosenbach's helper_test plugin. To test migrations see Atomic Object's migrationtesthelper plugin.

Why is pagination not working? [pagination]

Pagination is tricky to get right. An important step is to not use the built-in pagination code, but use a plugin instead. See Mike Garey's explanation, and discussion.

How can I debug a rails app? [debugging]

First, use tests to catch predictable bugs early. Second, look in the app's logs (in the log/ dir) to find stack traces after exceptions are raised. If you need a debugger, use rdebug. IDEs like RadRails and Netbeans have interfaces on top of rdebug, for visual step debugging.