RSS
31 Jan 2007

Beginning Ruby on Rails E-commerce: From Novice to Professional (Apress)

Author: ceefour | Filed under: Beginner, Books, E-commerce, News, Opinions, Praises, Rails, Reviews, Ruby, Tips, Web 2.0

Apress’ Beginning Ruby on Rails E-Commerce is easily one of the few (or the first?) Rails books who is able to broadly cover most aspects of Rails web development. Christian Hellsten and Jarkko Laine, the authors, will guide you from the point of installing the necessary software (including the Ubuntu Linux operating system), preparing the Scrum development process, to the very end of deployment and performance tuning. I say this book a “full-stack” since there’s not just development in here, but lots of bits about systems administration and project management.

<br />Apress recently offered me to review this book. Still unable to leave my old style of reviewing, here’s a narrative overview of each of the 13 chapters in tis book:

Chapter 1 quickly sets your development environment. If you follow its instructions to install Ubuntu, you’ll be getting up and running in no time (provided you have a good Internet connection). You will be introduced several concepts such as agile development techniques (it uses Scrum) but before you know it, you’ll already be running your first Rails application (and actually doing something, not just plain scaffolding) before the end of this chapter. You’ll be grateful there are so much introductory + practical information on the first chapter alone. In the example you’ll create a book store e-commerce application.

In Chapter 2 you’ll be introduced to basic CRUD (Create-Read-Update-Delete) actions on author management part of your application. You’ll like this so much since the first page of this chapter already mentions Test-Driven Development, and it is rightfully so for the next few pages. This is a very good habit, I’m very glad to see this getting more advocated. You’ll be implementing the actions from scratch (not using scaffolds), which is really a good thing (especially for learning how controllers and views work). This chapter has quite rich functional (controller) testing techniques.

Chapter 3 gets more to the point, you’ll implement yet another controller for book management. You’ll be presented with migrations, validations, more tests, model associations, unit testing with fixtures, and integration tests (seriously these are cool stuff!). In this chapter you’ll already finalized the administration facet of the application (in just two chapters, wow).

In Chapter 4 you’ll build the customer-oriented part of the application. It covers more (of course) testing, designing views, and eager loading of models. You’ll get some Google-y feeling as you implement the search functionality using Ferret and the acts_as_ferret plugin, which greatly simplifies the task. You’ll also create your own RSS feed generator, so your customers will always be updated with your latest offerings.

Chapter 5 guides you to implement a shopping cart, the last important step before you actually profit from your business. After doing some basic stuff like controller filters, it’s time for you to get the first Web 2.0 feeling using Ajax effects. All neat Script.aculo.us treats without a single line of JavaScript. Yummy! (it makes your customers happy too!)

While everything is set, it won’t be complete without a little touch of community. Ah, yes, in Chapter 6 you’ll be creating your very own forum for your site’s business. No, it’s not going to be frustrating because acts_as_threaded plugin will be ready to help you develop your forum the easy way. The under-the-hood forum threads implementation using nested sets is quite tricky actually, fortunately the plugin saves most of the headaches for you.

Got more love for Web 2.0? In Chapter 7 you’ll lift your site higher than your competitors using tagging support. Don’t worry, you’ll use a plugin/gem developed just for this purpose: acts_as_taggable, so your quest should be as stressless as possible. Note that there are now alternatives like acts_as_taggable_in_steroids and has_many_polymorphs, should you want to be adventurous.

In Chapter 8 you’ll create a login/authentication system, using a reusable component (of course): acts_as_authenticated. For registration and lost passwords you’ll need to send some e-mails, that’s where ActionMailer kicks in to help you. The chapter also talks a bit about common security attacks and how you can fortify your site from these bad guys.

Chapter 9 walks you through the most heart-pumping yet critical parts of your application: the checkout process. Stay worry free, ‘cuz Active Merchant will be there at your disposal. You’ll also integrate your application with payment gateways like Paypal, Authorize.net. Not only that, your customers will instantly be able to know exactly how much they’ve to pay for shipping on checkout, thanks to the Shipping gem.

For you who caters to international markets, Chapter 10 is definitely for you. The Globalize plugin allows you to internationalize your application, and localize everything from messages to date and time to currencies. You’ll also be prepared for exotic languages since you know application will handle them using Unicode. (Note: Ruby currently doesn’t have complete UTF-8 support, fortunately Rails 1.2 has pretty good support for Unicode for those who need it)

Chapter 11 deals with acceptance testing, which is a higher level than integration testing. You’ll use Selenium, a tool built for this purpose. This is the first time I’ve heard of this tool, so I can’t give much information about it. Rest assured, the author’s depth and breadth of coverage is excellent. Acceptance testing makes it easier and effortless to do tests that traditionally can only be done manually using a web browser by your QA team (if you have one icon smile Beginning Ruby on Rails E commerce: From Novice to Professional (Apress) .

In Chapter 12 you’ll deploy your application to a LightTPD web server, one or more FastCGI application servers, and a MySQL database server. Other alternatives (Apache, Mongrel) are discussed, but the book points you to online resources for these. You’ll be able to deploy your site automatically using Subversion and Capistrano. Soon enough “cap deploy” and “cap rollback” (hopefully seldom) are the only commands you’ll ever need to make the glorious new version of your site alive.

Chapter 13 lets you optimize your site’s performance, that begins with the absolute first: measuring, since you want to optimize what’s the real culprit of the slowness, not an already good code. (there’s almost always are tradeoff between performance and code readability/design). You’ll use Rails Analyzer and Action Profiler to do this. Next, there are some alternatives. Caching is probably the most obvious, and using several techniques, such as the popular memcached will give your site a nitro-boost (provided you have enough RAM). The authors also describe some common problems, including database and query design.

I was expecting an Appendix for quick reference commands and stuff at the end. But there isn’t! I hope the authors will add this on the next edition (I wish there will be!)

By the way, you should note that all of the tools/software used here are freely downloadable from the Internet without limitations. One of the greatest wonders of the open source movements and the worldwide network, indeed.

This is a Rails book which covers the widest aspects of web site development than most books, and I’d heartily recommend it to anyone who wants to build a real world Rails web site, not just e-commerce builders.

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

  • http://ameilij.wordpress.com Ariel Meilij

    Hey, nice review! Is it me, or the chapters look really long, not the kind of thing you get to read before going to sleep? It looks like just the book to buy, but I was wondering how does it compare to Agile Web Development (just curious…)

  • http://hendy.gauldong.net/ Hendy Irawan

    Dear Ariel,

    The book is definitely “not small”. It’s quite big, the size of a dictionary, but with half the thickness. (what kind of measurement is this?!?!)

    I’m not sure if it’s the kind of thing you “get to read before sleep” as it contains lots, and I mean lots, of code. It’s far from being a theoretical book.

    As for comparison with Agile Web Development with Rails (AWDWR), for beginners it’s not so important. They both introduce you to Rails from almost no background on Ruby, but good technical/computer background is somewhat required.

    AWDWR 2nd Edition describes Rails 1.2, which is the most recent version of Rails; while this book (RoR E-Commerce) still uses Rails 1.1. There is a change of some fine techniques but 90% is still the same.

    The biggest difference is that AWDWR is very, very detailed; while RoR E-Commerce is very, very broad. AWDWR takes a lot of the “build everything yourself” approach, while RoR E-Commerce uses plugins and reusable components to the max. RoR E-Commerce also suggests use of many complementary software such as Capistrano, Subversion, Selenium, acts_as_* plugins, etc.

    Conclusion is, both are great books. It won’t hurt to have either of them, since none of these is lousy. You can always get more later. ;-)

  • http://cpan.uwinnipeg.ca/~dns Daniel Sirait

    itu comment diatas kena spam yah ???

    pake Blosxom aja bung Hendy, download di: http://www.blosxom.com/

    ada plugin anti spam-nya, dijamin puas deh :-)

  • http://www.hendyirawan.web.id/ Hendy Irawan

    Thanks Mas Daniel,

    Di sini kita juga pake Akismet koq. Kita dapet ribuan spam per minggu, jadi kalo ada lolos segitu, bisa dibilang “kemajuan”. ;-)

    Biasanya spam tersebut juga akan otomatis hilang setelah beberapa waktu… :-)

    Kalo nggak, ya terpaksa pakai ‘tangan besi’… ;-)

  • Phillip Novess

    I bought this book because it was one of the only books out there, actually the only book out there that had any info on payment processing using Rails. It was also the only source at the time for real application of ecommerce development using Rails. However, its old now. The plugins have all been updated, Rails has been updated and the actual implementation that is being discussed through much of the book is not as valuable because of that. In fact I could not get the sample code to work without major removal of some of the plugins. The ActiveMerchant plugin was used for payment processing, the main reason I purchased the book, was majorly updated since this release and I actually had to change a large chunk of the processing code in order to get it to work. I actually had to use resources I found on the web to get ActiveMerchant to work correctly. Other downsides I found in the implementation was the shopping cart uses a DB, and then of course you have to keep this stuff cleaned up, so they use observers to do that. My question why? Just use a session for your cart like in the Agile book. Much simpler. If you really want that stuff in the DB, then use DB sessions. :) Also the checkout process is flawed in my opinion. When you checkout, the order gets created even if there is a problem with the the payment processing. One nice feature is it saves the error message to the order, which you inevitably will need to remove all the crap orders or at least to report on them. So a user could checkout and it processes and creates an order but its not really valid. Really really bad form!!!!!

    That being said I would still recommend this book for exploration and learning how others are using Rails. But don’t use this book as a blueprint cause its majorly flawed.

    -phill

  • http://hendy.gauldong.net/ Hendy Irawan

    Phillip:

    Thank you very much for your additional review. I really appreciate it. :-)

  • http://www.johnbeckseminar.com Christina joseph

    The book dives right into the process of creating a production-level web application using agile methodologies and test-driven development combined with Rails best practices.