Appendix A. An Incredibly Brief Introduction to Ruby

The protean nature of the computer is such that it can act like a machine or like a language to be shaped and exploited.

Alan Kay

Fortunately, you don’t need to know a whole lot of Ruby to get real work done with Rails. The creators of Rails have used many of Ruby’s most advanced features to make Rails easy to work with, but you can enjoy the benefits without having to know the details. This appendix explains the basics you’ll need to perform typical tasks in Rails and should help you get started. For a lot more detail on Ruby, try Learning Ruby (O’Reilly, 2007), The Ruby Programming Language (O’Reilly, 2008), The Well-Grounded Rubyist (Manning, 2014), or Head First Ruby (O’Reilly, 2015). Also check out the tutorials at Try Ruby.

Note

If you’ve never worked with a programming language before, this appendix may go too fast for you. It’s hard to be incredibly brief and cover the basics at the same time. Ruby is a beautiful but sometimes mystifying language. Its syntax is very robust, which means there is a lot of flexibility, but also that it’s sometimes difficult to decipher.

Because this is a Rails book, examples will work inside of the Rails framework, in a Rails view and controller, rather than from the command line. If you haven’t touched Rails before, it makes sense to read Chapter 1 first and get Rails installed, and then come back here for more instruction.

How Ruby Works

Ruby is an object-oriented ...

Get Learning Rails 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.