Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Book Reviews Books Media

Rails Recipes 153

James Edward Gray II writes "If you have been swept up by the Rails craze or are even just a casual fan, you have probably been waiting for the terrific books to start rolling in. Some early entries, like Agile Web Development with Rails, were very solid but for me greatness arrived with Rails Recipes. For those who are not familiar with it, Rails is a full-stack web application framework, for quickly developing state-of-the-art web applications. Rails Recipes is the latest book on the subject from the Pragmatic Programmers." Read the rest of James's review.
Rails Recipes
author Recipes
pages 299
publisher The Pragmatic Programmers
rating Excellent
reviewer James Edward Gray II
ISBN 0-9776166-0-6
summary A programming cookbook for all things Rails.


Let me tell you how I discovered Rails Recipes. At the Rails shop I work for, we needed a favorites system for our latest application. When I inherited the task of implementing favorites, I had heard just enough to guess that the new polymorphic associations feature of Rails might be just what I needed. Sadly, I had never even seen an example of their usage. Before leaving work that day, I checked the table of contents to make sure a recipe for what I needed was in there and and bought a combo pack, so the PDF would be waiting for me in the morning. The next day I built the entire favorites system and integrated it into our application with only the book as my guide. Total time for implementation, from cracking the book to a complete solution: just over three hours.

Needless to say, the book had completely won me over by that point. I started sneaking in recipe reads whenever I had a free moment or two and had literally devoured the book in no time. I completely expected it to show me cute AJAX tricks and handle common issues like login code and it certainly does these things. It also covers popular plugins, including Acts as Taggable and Acts as Versioned, as it should. What I didn't expect was for the book to include so many excellent low-flash coding recommendations as well. There are terrific recipes for DRYing up your code in various circumstances, building your own output forms for views, how to use models in migrations even if the files are long gone, integration testing as a DSL, routing methods, code generation, and a whole lot more.

The book has some surprising depth to the Rails insights it provides, not because the recipes are long but more because the topics are well chosen. Even the small "Snack Recipes" generally dive right to the heart of a commonly encountered matter. You get typical solutions and often some tips on how to customize the relevant Rails behaviors. For example, the book covers how to add inflections Rails can use in its singular/plural text transformations and how to tie your own form building classes right into the standard Rails helper methods.

I'm a long time Ruby user and I consider myself fairly knowledgeable with regard to the language, but this book taught me new tricks. I've read the Pickaxe, but for some reason IRb sessions never sunk in for me until this book showed the perfect example of using the on an ActiveRecord model to create a Ruby syntax database shell. The book even taught me some great YAML tricks for use in fixtures and configuration files.

Now I realize I've been gushing a little, so let me to balance it with at least some words of caution. First, this book assumes you know Rails. You will not learn Rails here. This should not be the first Rails book you read, though it does make an ideal second read and daily reference. I should also note that the recipe sections seem pretty arbitrary to me. I expected to find the login discussion in the "Big-Picture Recipes" section and the console tips in "Database Recipes", but they are located elsewhere. This might be a minor challenge for those who try to thumb straight to a recipe, but I've found searching the PDF makes this a non-issue. (The paper version of the book does have nice tabs drawn on the edge of pages to lead you to recipe types though, unrelated to the sections.) Finally, I should note that I've gone hunting in the book for about four work projects now, and found all but one. It didn't cover Acts as Threaded usage. Obviously it is impossible for a single book to answer all your questions about Rails, but a 75% ratio seems like a great start to me!

There are 70 recipes in this book split among user interface, database, controller, testing, big-picture, and email categories. I must stress again though how well these recipes pack in the tips. Don't be at all surprised if you learn an applicable view layer or even pure Ruby trick in a database recipe.

If you are a Rails user, I must recommend you pick up this title immediately. I really believe there is something in here for all.


You can purchase Rails Recipes from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Rails Recipes

Comments Filter:
  • by Super Dave Osbourne ( 688888 ) on Monday December 11, 2006 @04:18PM (#17199004)
    Rails has been around for a while, and the books are all pretty good (bought 5, read 5, returned 5)... The only book really worth reading to any seasoned MVC or Morphic programmer is the Getting Started with Rails... The rest are really just rehash on MVC which is so dated we should all look carefully at why Rails is so special to the masses in the first place.
  • James' Books (Score:3, Interesting)

    by Super Dave Osbourne ( 688888 ) on Monday December 11, 2006 @04:21PM (#17199058)
    James is a good guy, and knows his Mac crack. Guys has been alive and well in the community for 3 years, and is a great guy with the Ruby Quiz. Conflicting publisher (or not) his views are almost always well thought out and valid, regardless of how silly and useful the Quiz is :) Glad to see James has a TextMate book coming out with Oreilly. In all, the book itself (the Rails Recipes) is about a 7-8 out of 10 mac strokes.
  • From the review:

    Now I realize I've been gushing a little, so let me to balance it with at least some words of caution. First, this book assumes you know Rails. You will not learn Rails here.

    Actually, I could hardly read your review, since it was so crammed with non-standard jargon (at least, from my perspective as a longtime C++/Java programmer). Lighten up on the Ruby-specific buzzwords, please! "how to use models in migrations", "integration testing as a DSL", "great YAML tricks for use in fixtures", huh???? It's nice that the book taught you how to do those things, whatever they are, but maybe a review should relate these things to more normal (non-Ruby) programmers' experiences in common language somehow.

  • by resonantblue ( 950315 ) on Monday December 11, 2006 @05:17PM (#17199868)

    Because it's not compiled, it seems like it's not a good idea for really large projects either.
    You wanna bet? Look at 37signals which successfully runs large projects on Rails. It's not compiled, but neither is PHP. Since Rails runs as a persistent app, in a production environment, it only loads most of the application into memory once. At that point, in all practicality, you will hardly ever run into performance bottlenecks that can't be fixed by scaling out.

    Admittedly, Rails debugging tools cannot compare to those of .NET or J2EE, but the issue of being compiled will hardly ever come up in practicality.

    really couldn't find any reason why I'd want to use it above PHP
    Cause it's a fully integrated framework. Try using plain, vanilla PHP and see how much boilerplate code you write to connect to your database, to retrieve data, to implement Ajax. Then tell me how easy it keep your code clean and modularized when you start to build up your site. And don't even get me started on building automated tests into your application. I used use PHP exclusively, but I've never looked back.

    As a side note, there are some frameworks in PHP now that can compare to the Rails way of doing things (like CakePHP or Symphony). I still prefer Ruby as a language, but those frameworks seem pretty decent. However, I don't think you can compare pure vanilla PHP to Rails.

    Here's why I didn't like it. If your building a small project, the model-view-controller thing can get really annoying, with the needing of 3 files for a single web page thing.
    Yeah, the whole thing about writing good, clean code is pretty annoying. If you're ok with writing shitty code, then by all means, don't ever use Rails :-)

    -Aamer
  • by smallpaul ( 65919 ) <paul@@@prescod...net> on Monday December 11, 2006 @05:17PM (#17199876)
    What makes you think that software needs to be "compiled" for large projects? Yahoo is primarily delivered with PHP. Amazon.com is largely Perl. MySpace is largely ColdFusion (migrating to .NET). Yahoo: http://www.internetnews.com/dev-news/article.php/1 491221 [internetnews.com] Amazon: http://en.wikipedia.org/wiki/Mason_(Perl) [wikipedia.org] MySpace: http://www.tomasbecklin.com/cf/ [tomasbecklin.com]
  • by aiosx ( 967062 ) on Monday December 11, 2006 @05:40PM (#17200176)

    Lighten up on the Ruby-specific buzzwords, please! "how to use models in migrations", "integration testing as a DSL", "great YAML tricks for use in fixtures", huh???? It's nice that the book taught you how to do those things, whatever they are, but maybe a review should relate these things to more normal (non-Ruby) programmers

    Most of those _are_ 'normal' terms.

    Models are a fundamental part of the MVC [wikipedia.org] design pattern (which originated in 1979 [ifi.uio.no], so it isn't exactly a rails buzzword!), integration testing [wikipedia.org] is part of general software testing, usually used in combination with unit testing, and YAML [wikipedia.org] is a markup language (sort of). They aren't Ruby or Rails specific.

    Don't assume you know all the 'normal' terms simply because you don't consider yourself a newby. You sound like one of those programers who think they know it all... boy are those a pain to work with. They're almost always the ones that know the least.

  • by dankelley ( 573611 ) on Monday December 11, 2006 @07:10PM (#17201352)

    Well, there is an excuse left, if you're a PHP programmer looking for a replacement (be that django or rails) -- it's the issue of how to deploy the sucker.

    I might be like some others reading this thread. I'm familiar with PHP and I'd like to switch up to something more elegant.

    But there's a roadblock when it comes to deployment.

    With PHP, it's simple -- your test machine is probably set up already, and your deployment webserver almost certainly is. With Rails and Django, you're in a spot of trouble, since it's quite likely that neither your development machine nor your deployment webserver is set up. It's not trivial to just install "mod" modules to get Rails and Django to work, and you have to own root permissions to do that.

    So, a typical user can start creating PHP sites easily, but these wonderful frameworks are a bit difficult. Is it worth the effort? Well, I've only looked into Django in any detail, and I think the answer is "yes", but I'd sure love to see the folks who are writing the Django book drop whatever chapter they are writing and move on to the deployment chapter. That test server they keep talking about is just not very helpful. I need something that I can leave running (efficiently) so that I can get user feedback on my site. The little server they provide, and describe carefully in their document, it's a screwdriver and I need a hammer.

  • Comment removed (Score:3, Interesting)

    by account_deleted ( 4530225 ) on Tuesday December 12, 2006 @12:21AM (#17203888)
    Comment removed based on user account deletion

Thus spake the master programmer: "After three days without programming, life becomes meaningless." -- Geoffrey James, "The Tao of Programming"

Working...