Skip to Content
Advanced Rails
book

Advanced Rails

by Brad Ediger
December 2007
Intermediate to advanced
357 pages
10h 48m
English
O'Reilly Media, Inc.
Content preview from Advanced Rails

Chapter 2. ActiveSupport and RailTies

[Programs] must be written for people to read, and only incidentally for machines to execute.

—H. Abelson and G. Sussmann

Structure and Interpretation of Computer Programs, MIT Press, 1985

We continue in our bottom-up view of Rails by examining the pieces that form the basis for Rails. ActiveSupport is a library that provides generic, reusable functions that are not specific to any one part of Rails. We can use many of these methods ourselves when writing our application code. RailTies is the other half, containing parts that glue Rails together in a Rails-specific way. Although we will not usually use RailTies functions in our own code, it is important and instructive to examine them.

Most of this chapter is nonsequential; feel free to skip around. However, in accordance with our bottom-up approach to Rails, later chapters will build on this material.

Ruby You May Have Missed

It is very easy to overlook some of Ruby’s more useful methods. The best way to find them is to read code. Here are some of the more obscure, but helpful, ones.

Array

  • Array#* an operate as Array#join (if given a string or stringlike argument); it also does repetition:

    	[1, 2, 3] * "; " # => "1; 2; 3"
    
    	[0] * 5 # => [0, 0, 0, 0, 0]
  • Array#pack and String#unpack are useful for working with binary files. why the lucky stiff uses Array#pack to stuff a series of numbers into a BMP-formatted sparkline graph without any heavy image libraries, in 13 lines of code (http://redhanded.hobix.com/inspect/sparklinesForMinimalists.html ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Rails Crash Course

Rails Crash Course

Anthony Lewis
Learning Rails 5

Learning Rails 5

J. Mark Locklear, Eric J Gruber, Barnabas Bulpett

Publisher Resources

ISBN: 9780596510329Errata Page