small medium large xlarge

Back to: All Forums  The Rails View
06 Apr 2012, 20:03
John M Athayde (29 posts)

Change log:

  • Fixed code installation instructions, overview, and other documentation.
  • Easier chapter level Rails application setup (“rake setup”)
  • Unified and expanded database schema across applications
  • Miscellaneous functional fixes to chapter applications
  • Fixed code errata (typos and minor edits)
06 Apr 2012, 22:20
John M Athayde (29 posts)

Looks like the readme file didn’t get into the code. Here it is:

Rails applications for chapters

Each directory contains a Rails application for a specific chapter:

  • css: “Adding Cascading Style Sheets”
  • email: “Working with Email”
  • forms: “Building Maintainable Forms”
  • js: “Adding JavaScript”
  • layout: “Creating an Application Layout”
  • performance: “Optimizing Performance”
  • presenters: “Using Presenters”
  • readability: “Improving Readability”
  • responsive: “Handling Mobile Views”


Each application is designed to illustrate the concepts described in the associated chapter. Some things to note:

  • Authentication, authorization, and model scoping are largely stubbed out (or left intentionally missing) so we can focus on the view.
  • You may notice files named with a versioning convention, e.g., @file.v1.html.erb@, @file.v2.html.erb@, etc. These files are used in the the book to incrementally describe the associated runnable file (e.g., @file.html.erb@).
  • While we’ve made an effort to have the application behave consistently across chapters, because the book focuses on the view layer (and each chapter is somewhat of a vignette on a specific subject) all the changes between chapters may not covered by the text.
  • Click around enough, and you’re bound to find broken links. While we have stubs in place for the larger uncovered features of the application, some things are still missing.
  • If you run into problems with the code, please let is know through on of the methods listed in the main README for the code download.

Application Setup

A Note on Ruby

Each application includes an @.rvmrc@ file for use with [RVM][1], configuring the environment to use Ruby 1.9.3 and a gemset, @therailsview@. You can [install Ruby 1.9.3 with RVM][2] if you don’t already have it, and the gemset will be created if it doesn’t exist.

You don’t need to use RVM or a gemset if you prefer. Just keep in mind the code was built using Ruby 1.9.3; it will probably run on other 1.9.X versions, but is not compatible out-of-the-box, for instance, with Ruby 1.8.X.

For more information see the Preface in the book text.

Installing dependencies

To get a chapter application running, first change to that directory by doing the following (where ‘CHAPTER’ is the directory for the chapter, e.g. @layout@):

cd artflow/CHAPTER

(If you are using RVM, it may prompt you to confirm that you trust the @.rvmrc@ at this point.)

If you haven’t installed it yet, you need [Bundler][3]:

gem install bundler

Install the dependencies for the application:

bundle install

Installation Problems

Please report any issues you have installing [on the forum][5]. It’s possible someone has already pointed out a solution.

Here are some known issues:


If you run into a problem installing Nokogiri, first see the [Nokogiri installation instructions][4].

Problems have been reported with OSX Lion and Xcode 4. libxml2, libxslt, and libiconv may need to be installed separately with Homebrew, MacPorts, or manually.

Once you have the dependencies installed, set up the database.

Setting up the database

To get the (SQLite3) database set-up and ready to go, we’ve provided a single Rake task, @setup@. Do the following:

rake setup

(If you’d like to use something other than Rails’ default of SQLite3, you’ll need to edit the @config/database.yml@, modify the @Gemfile@, and install those dependencies, as appropriate.)

Next, start the server and view the site:

Starting the server

Start the server with the @rails@ executable:

rails server

Now point your favorite browser (we recommend Chrome or Firefox) at:


IMPORTANT: Check the README of the specific chapter (@artflow/CHAPTER/ for specifics on the URLs to view.

1: 2: 3: 4: 5:

06 Apr 2012, 21:49
Bharat Ruparel (148 posts)

Nice! Will review and be in touch :) Bharat

07 Apr 2012, 02:58
Akshay Kumar (6 posts)

Shweet. I tired the app for the layout chapter earlier today. So far looks good.

07 Apr 2012, 07:23
Michael Schuerig (12 posts)

I’m unclear if the example apps are meant mostly as illustration or whether they are supposed to work.

  • Migrations are inconsistent: table “designers” is created by two migrations, 20110926060144_create_designers.rb and 20111008052704_devise_create_designers.rb. Therefore, while rake db:setup works, as it only looks at db/schema.rb, rake db:migrate fails.

  • rake test results in lots of errors and failures.

  • When running and interacting with a chapter app, exceptions are raised because of nil objects.

I can give more specifics, if needed. But, as I said, I’m not sure if the code is even expected to work perfectly.

07 Apr 2012, 09:08
Bruce Williams (20 posts)


Thanks for the comment. Specifics would be helpful I think; this is just the first in several updates as we progress through errata and work to make the examples more consistent across chapters (a problem we’ve run into due to divergent branches and a chapter reordering). We’re especially interested in failures during the documented setup and at the specific URLs covered in the chapters. You’re right in that the apps are supposed to illustrate specific techniques in the view; they’re certainly not fully exercisable apps (not least of which because we stub out authentication)… but they should work as described in the book. If they don’t, then it’s something we’ll fix as quickly as possible (and, in the interim, add to a list of known issues).

Thanks again for the feedback, we really do appreciate it.

(Note: I’ll be out for the weekend, family plans off the grid, so please forgive my inevitable late replies.)

07 Apr 2012, 15:25
Mark (6 posts)

Living in the UK amazon are reporting that its for some reason (usually shipped within 3-6 weeks) to obtain this new book, Rails Recipes: Rails 3 Edition and The cucumber book. Only ‘The cucumber book’ being in stock.

In order to get a head start I’ve been waiting for the this book to be published, so downloaded the code while I wait for my books to arrive.

I’ve hit a problem with running in the layouts application of the artwork chapter.

rake setup generates the following error:

– initialize_schema_migrations_table() -> 0.0048s – assume_migrated_upto_version(20120405113228, [“/Users/development/railsprojects/pragmatic/TheRailsView/trv-downloaded-code/artflow/layout/db/migrate”]) -> 0.0759s rake aborted! Validation failed: File Could not run the identify command. Please install ImageMagick., File Could not run the identify command. Please install ImageMagick., File Could not run the identify command. Please install ImageMagick.

Is this mentioned in the body of the chapter? Obviously at present I don’t have the ebook or physical book. I’m running on OSX Snow Leopard (OXS 10.6), have installed ruby 1.9.3 via the .rvmrc file but am using homebrew or macports.

Can you please advise if this is a genuine problem and what the cleanest solution is?

Thanks for putting in what would appear to be some long hours to sort out initial teething issues with the book. Are you including this in the Hungry Academy teachings? I’ve been following along with this as well, as not being a US resident could not apply to the internship programme. It looks to be a great pressure cooker/high intensity/fun environment to be in and supported by some knowledgable software engineers who are keen to help shape the futures of those lucky enough to be successful in applying. It would be great to see something like this in the UK where I currently live.

Please don’t take this as a criticism. I’d be interested in understanding why this book didn’t go through the existing beta process?

Thank you

P.S. Pragpress - I’d order directly from you if you could match/get near the UK amazon pricing as this keeps the overall cost down as I’d like to buy the electronic copy as well and I know you discount these once you have the paper copy (from your email previously). I have no ideas what the shipping charges to the UK are and given the frequency I find myself purchasing your Rails/HTML/CSS and associated books, I’m sure it would add up quite quickly. Any ideas why Amazon UK has 3-6 week lead time? Is it due to surface shipping?

What publishing mechanism are you utilizing for your ebooks. I learnt Rails from Michael Hartl’s excellent screencasts/pdf which have recently been update for Rails 3.2. He has published a screencast on the publishing process he uses, and it appears that for ebooks he can make updates on the fly. Are you using a similar system?

07 Apr 2012, 15:12
Bruce Williams (20 posts)

M Sutton, it looks like you’re missing ImageMagick, one of the dependencies of Paperclip (, used to generate thumbnails.

07 Apr 2012, 18:11
John M Athayde (29 posts)

M Sutton: This might help get you up and running faster

In regards to your PS questions, those are things that the publisher would know (with regard to UK lead time). I conjecture that it involves book delivery to UK distribution centers, but I can’t be sure. PragProg has a custom system for the way their books are created. Being a larger organization, it’s not as easy to just spit out an update, especially when it causes the pages to reflow, as there’s a lot of time and effort spent in making sure the book layout works well.

07 Apr 2012, 19:11
Mark (6 posts)


Thanks for the very quick response. I googled between sending this & receiving your response and came up with the same solution.

I had to edit the download as it failed initially (I think it was due to md5 checksums from further googling). It was on the fonts ‘package’.

I’m looking forward to my book arriving as I like the pragmatic style of writing.

Thanks once again


08 Apr 2012, 22:52
Bharat Ruparel (148 posts)

I am going through the layouts chapter and is looking good! It is amazing how much a real working “demo/prototype/stubbed out app” can do to make your reading go smooth :) Good work! Thanks. Bharat

09 Apr 2012, 02:36
Bruce Williams (20 posts)

Thanks Bharat! Let us know if you run into any snags down the line and we’ll fix them as quickly as possible!

12 Apr 2012, 13:22
Alex Dearden (10 posts)

Downloaded latest code version went into artflow/responsive chapter issued Bundle install (no errors) issued rake setup (as instructed above) got the following errors:

rake aborted! Validation failed: File /var/folders/yr/x0yy66ts7v598ywf4_hkmrx40000gn/T/rubyconf2011-shirt-back.png20120412-38434-sfvvg2 is not recognized by the ‘identify’ command., File /var/folders/yr/x0yy66ts7v598ywf4_hkmrx40000gn/T/rubyconf2011-shirt-back.png20120412-38434-sfvvg2 is not recognized by the ‘identify’ command., File /var/folders/yr/x0yy66ts7v598ywf4_hkmrx40000gn/T/rubyconf2011-shirt-back.png20120412-38434-sfvvg2 is not recognized by the ‘identify’ command., File /var/folders/yr/x0yy66ts7v598ywf4_hkmrx40000gn/T/rubyconf2011-shirt-back.png20120412-38434-sfvvg2 is not recognized by the ‘identify’ command.

Cleaning up the content of /var/folder (seems it’s an Xcode-related thing) then produces the following error:

rake aborted! Validation failed: File /tmp/rubyconf2011-shirt-back.png20120412-38755-39er1u is not recognized by the ‘identify’ command., File /tmp/rubyconf2011-shirt-back.png20120412-38755-39er1u is not recognized by the ‘identify’ command., File /tmp/rubyconf2011-shirt-back.png20120412-38755-39er1u is not recognized by the ‘identify’ command., File /tmp/rubyconf2011-shirt-back.png20120412-38755-39er1u is not recognized by the ‘identify’ command.

These files do not exist in /tmp so I’m assuming the rake setup command is somehow creating them. I can see them flash across a finder window when running rake setup. Moreover, the contents for /var/folders get recreated when running rake setup.

Please advise.

17 Apr 2012, 02:55
Bruce Williams (20 posts)


Sorry about the late response; last week was a rough one. These are coming out of Paperclip presumably. What is your ImageMagick (Paperclip native dependency) version? I can’t reproduce the problem locally.

09 May 2012, 10:41
Alex Dearden (10 posts)

Hi Bruce, hadn’t had time to come back to this. In all honesty I got so discouraged that I stopped reading the book altogether. I gave up. I’d like to really get back in the book as soon as I have some time which might be soon. So to answer your question:

I have no idea what paperclip is or how to find out what version of imageMagick I have. If they are gems I don’t have them installed.

The only imagemagick I know of was a PHP library way back when.

Please advice.

08 Jul 2012, 00:42
John M Athayde (29 posts)

Alex -

To find out if you have imagemagick installed, I’d open up terminal and use locate imagemagick to determine if it’s installed. You might need to spin up your locate service (locatedb) if you’ve never used it before. If you didn’t install it in the past, it’s safe to assume you don’t have it. In that case, I’d recommend using Homebrew and using that to install ImageMagick (‘brew install imagemagick’). That’ll handle the dependencies.

From there, you need the rmagick gem in your app, which should already be in the gemfile. You may need to redo bundle to get it to see the binary of ImageMagick (which is actually a series of binaries).

I’m sorry Bruce hasn’t replied, we’ve both been a bit slammed at work and are trying to get back on the horse with edits and articles.