Apress has just come out with two interesting releases in the Ruby and Rails spectrum. Beginning Ruby on Rails is a truly beginner-level book so if you felt other books were a bit overwhelming, it might be an excellent tome to start with. If you take the word of Hampton for it, the book should be a really excellent intro.

Another interesting new title is Practical Ruby for System Administration. One of the most obvious use cases for Ruby is as an “enterprise glue”, and that’s exactly what AndrĂ© Ben Hamou will teach you in his book.

(via Ruby Inside)

ruby-prof 0.5.0 is out

July 24th, 2007

We briefly mentioned ruby-prof in the performance optimization chapter of the book. At the time there were some compatibility issues between ActionProfiler and ruby-prof, however. Now Charlie Savage has come out with an all-new version of his profiler, ruby-prof 0.5.0. According to Peter Cooper, the new version “is a major leap forward”, which seems to indeed be true.

Reviews pouring in

February 18th, 2007

We’ve got some nice reviews even outside the standard Amazon.com page. Rails superhero Jamis Buck wrote a very positive detailed review, as did Hendy Irawan. Even Java cowboys seem to love the book :-)

Errata

January 20th, 2007

We spent a good part of the holidays working through all the great errata requests we have received, and the list is finally ready for publishing.

Thanks to everybody who have taken the time to point out corrections, we really appreciate it. Keep’em coming!

Pat Eyler over at On Ruby just published an interview with Christian. If you want to get a closer look at Christian’s thoughts about Rails, Ruby, Python, Java and all things related, go have a look. I was the “victim” of a similar interview in November.

On Ruby also sports a blogging contest for all who are interested in learning and teaching Ruby and Rails by writing. I had the honour to come up with the theme for the January 2007 edition and am also sitting in the the grand jury picking up the winners this month. I wrote a longer article about this month’s theme in my weblog.

Discussion Group is alive!

December 12th, 2006

The discussion about the book seems to be very lively on the Rails mailing list. Unfortunately the amount of traffic on the list is huge so it’s really hard to spot the posts related to the book from there. Therefore, I created a new list just for discussion about our book.

The list can be found at groups.google.com/group/railsecommerce and works exactly as the Rails lists do. So go ahead and post your enquiries and questions there.

Call for article proposals

November 16th, 2006

We’re going to write articles on this site about topics that are related to Rails and e-commerce but that didn’t make the cut for the actual book. What would you like to read tutorials about? We’ve already been suggested writing about discount packages (real discounts, not the standard amazon packages where you pay as much as the two would cost separately) and hooking the JS auto-completion with AJAX. Anything else? The floor is yours.

Write your proposals in the comment form or – if you’re shy – directly to me (jarkko@jlaine.net).

Table of Contents

November 10th, 2006

CHAPTER 1 Project Setup and Proof of Concept
Introducing the Emporium Project 1
Installing the Software 2
Installing Ruby 4
Installing RubyGems 5
Installing Ruby on Rails 6
Installing MySQL 8
Installing the MySQL Driver 9
Introducing Scrum 10
Creating the Emporium Application 12
Creating the Skeleton Application 12
Creating the Emporium Database 14
Starting Emporium for the First Time 18
How Does Ruby on Rails Work? 20
Implementing the About Emporium User Story 20
Running the Generate Script 21
Modifying the Generated View 22
Creating the Layout 23
Modifying the Generated Controller 27
Summary 28
CHAPTER 2 Author Management
Using Test-Driven Development 29
Testing in Rails 30
Unit Testing 30
Functional Testing 31
Integration Testing 31
Creating the ActiveRecord Model 31
Using ActiveRecord Migrations 32
Running Unit Tests 36
Creating the Controller 37
Implementing the User Stories 39
Adding an Author 39
Listing Authors 48
Viewing an Author 50
Editing an Author 52
Deleting an Author 54
Adjusting the Flash Notifications 55
Summary 57
CHAPTER 3 Book Inventory Management
Getting the Requirements 59
Using Scaffolding 60
Implementing the Publisher Administration Interface 61
Updating the Schema with the Publishers Table 61
Generating Publisher Code with the Scaffolding Script 62
Completing the Add Publisher User Story 64
Completing the View Publisher User Story 66
Completing the Edit Publisher User Story 68
Implementing the Book Administration Interface 69
Updating the Schema with the Books Table 69
Creating the Book Model 73
ActiveRecord Mapping 73
Modifying the Generated Models 77
Cloning the Database 80
Unit Testing Validations 81
Unit Testing the ActiveRecord Mappings 82
Generating Book Administration Code with the Scaffolding Script 88
Integration Testing 90
Completing the Add Book User Story 91
Completing the Upload Book Cover User Story 102
Completing the List Books User Story 104
Completing the View Book User Story 107
Completing the Edit Book User Story 110
Testing the Delete Book User Story 112
Summary 112
CHAPTER 4 Book Catalog Browsing
Getting the Book Catalog Requirements 113
Implementing the Book Catalog Interface 114
Implementing the Browse Books User Story 116
Implementing the View Book Details User Story 120
Implementing the Search Books User Story 125
Implementing the Get Latest Books User Story 133
Creating an RSS Feed 136
Summary 139
CHAPTER 5 Shopping Cart Implementation
Getting the Shopping Cart Requirements 141
Setting Up the Shopping Cart 142
Creating the Controller 142
Adding a Functional Test 142
Creating the Models 143
Modifying the Controller 145
Creating the Views 147
Implementing the User Stories 152
Implementing the Add Items to the Cart User Story 152
Implementing the Remove Items from the Cart User Story 161
Implementing the Clear the Cart User Story 166
Summary 168
CHAPTER 6 Forum Implementation
Getting the Forum Requirements 169
Using the Threaded Forum Plugin 170
Setting Up the Forum 171
Updating the Database Schema 171
Modifying the Model 175
Unit Testing the Model 176
Generating the Controller and View 177
Implementing the User Stories 179
Implementing the Post to Forum User Story 179
Implementing the View Forum User Story 185
Implementing the View Post User Story 190
Implementing the Reply to Post User Story 192
Summary 195
CHAPTER 7 Tagging Support
Getting the Tagging Requirements 197
Using the Tagging RubyGem 198
Setting Up for Tagging 201
Updating the Database Schema 201
Preparing the Models 203
Unit Testing the Model 204
Using the Console to Test the Model 205
Implementing the User Stories 207
Implementing the Assign Tags User Story 207
Implementing the Edit Tags User Story 211
Implementing the List Tags and Show Tag User Stories 215
Implementing the Recommend Books User Story 218
Summary 221
CHAPTER 8 Security
Getting the Authentication Requirements 223
Using the Authentication Plugin 224
Implementing the User Stories 227
Implementing the Log In User Story 227
Implementing the Fail Log In User Story 233
Implementing the Reset Password User Story 238
Protecting Your Application 248
Cross-Site Scripting 248
URL and Form Manipulation 248
SQL Injection 249
Cross-Site Request Forgery 250
Summary 250
CHAPTER 9 Checkout and Order Processing
Getting the Checkout and Order-Processing Requirements 252
Implementing the Check Out User Story 252
Creating the Models 252
Adding Validations to the Model 257
Creating the Controller and Integration Test 259
Creating the View 262
Saving the Order Information 268
Integrating with Payment Gateways 271
Installing the Active Merchant Plugin 271
Integrating with PayPal 272
Integrating with AuthorizeNet 280
Using the Payment Gem 284
Implementing the Administrator User Stories 286
Implementing the View Orders User Story 286
Implementing the View Order User Story 290
Implementing the Close Order User Story 292
Calculating Shipping Costs and Taxes 294
Using the Shipping Gem 294
Calculating Taxes 296
Summary 296
CHAPTER 10 Multiple Language Support
Getting the Localization Requirements 297
Using the Globalize Plugin 298
Localizing with Globalize 300
Setting Up Globalize 303
Implementing the User Stories 304
Implementing the Change Locale User Story 304
Implementing the Translation User Stories 306
Translating the View and the Book Model 313
Translating the View 313
Translating the Model 317
Localizing Dates, Numbers, and Currency 319
Localizing Dates 319
Localizing Numbers and Currencies 320
Adding Unicode (UTF-8) Support 322
Setting Character Encoding in HTML 323
Setting Character Encoding for the HTTP Response 324
Changing the Database to Use UTF-8 324
Summary 326
CHAPTER 11 Acceptance Testing
Using Selenium 327
Writing Selenium Tests 330
Selenium Commands 330
Selenium Test Formats 334
The First Acceptance Test 335
Recording Selenium Tests 337
Using the Selenium IDE 337
Recording the View Forum Acceptance Test 340
Recording the Post to Forum Acceptance Test 345
Recording the Show Post Acceptance Test 347
Recording the Reply to Post Acceptance Test 348
Summary 350
CHAPTER 12 Application Deployment
Setting Up the Production Environment 351
Connecting to the Production Server: SSH 352
Installing the Web Server: LightTPD 353
Installing the Application Server: Ruby on Rails and FastCGI 356
Installing the Database Server (MySQL) 358
Configuring LightTPD 358
Creating the Production Database 365
Deploying the Application Manually 366
Copying the Application 367
Creating Users and Groups 367
Starting LightTPD 368
Starting FastCGI Processes 369
Automating Deployment 371
Installing Capistrano 371
Creating the Capistrano Deployment Recipe 371
Running the Setup Task 375
Deploying to Production 376
Starting LightTPD 379
Summary 380
CHAPTER 13 Performance Optimization
Performance and Scaling 381
Measuring Performance 382
Checking the Log File 382
Using Rails Analyzer 383
Caching 388
Page Caching 388
Action Caching 390
Fragment Caching 390
Fragment Stores 392
Caching ActiveRecord Objects 395
Common Performance Problems in Rails 397
Rendering Speed 397
Database Access 399
Summary 401

Dear Rails Enthusiast,

We just got email from our editor Keir where he said he’d got his hands on our new book, Beginning Rails E-Commerce. His mail didn’t include the words “f*cking awesome”, but instead “superb” and “a work of art”, which we think are almost as good.

This means that the book will hit the shelves before you can say “Heinemeier”, so be sure to get yours while it’s still hot.

We wanted to make our book such that you can “read” it while you’re sitting in front of your computer. It’s completely project-driven, meaning the content is divided by task, and that you can build the sample application in small iterations, learning the background details on the fly.

As one of the core philosophies of Rails is to support best practices, we decided to do that as well. Most of the tasks are written test-driven, giving you a glimpse of the ease with which TDD can be used in Rails and the power it brings compared to a traditional, ad-hoc web application development process.

We hope you enjoy the book as much as we enjoyed the journey of writing it.

Buy the book

Best,

Christian Hellsten and Jarkko Laine

Sample Code

November 7th, 2006

On this page you can find the sample code for the book.

By Chapter:

  1. Chapter 1
  2. Chapter 2
  3. Chapter 3
  4. Chapter 4
  5. Chapter 5
  6. Chapter 6
  7. Chapter 7
  8. Chapter 8
  9. Chapter 9
  10. Chapter 10
  11. Chapter 11
  12. Chapter 12
  13. Chapter 13

All chapters at once (4.8MB)