Tải bản đầy đủ (.pdf) (592 trang)

rails 3 in action

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (8.14 MB, 592 trang )

MANNING
Ryan Bigg
Yehuda Katz
IN ACTION
www.it-ebooks.info
Rails 3 in Action
www.it-ebooks.info
www.it-ebooks.info
Rails 3 in Action
RYAN BIGG
YEHUDA KATZ
MANNING
SHELTER ISLAND
www.it-ebooks.info
iv
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 261
Shelter Island, NY 11964
Email:
©2012 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps


or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.
Manning Publications Co. Development editor: Cynthia Kane
20 Baldwin Road Copyeditors: Kevin Hobson, Linda Kern
PO Box 261 Proofreader: Tiffany Taylor
Shelter Island, NY 11964 Typesetter: Dottie Marsico
Cover designer: Marija Tudor
ISBN 978-1-935182-27-6
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 16 15 14 13 12 11
www.it-ebooks.info
v
brief contents
1

Ruby on Rails, the framework 1
2

Testing saves your bacon 23
3

Developing a real Rails application 44
4

Oh CRUD! 83
5


Nested resources 99
6

Authentication and basic authorization 117
7

Basic access control 136
8

More authorization 164
9

File uploading 213
10

Tracking state 243
11

Tagging 286
12

Sending email 312
13

Designing an API 347
14

Deployment 385
15


Alternative authentication 412
16

Basic performance enhancements 434
17

Engines 468
18

Rack-based applications 516
www.it-ebooks.info
www.it-ebooks.info
vii
contents
preface xv
acknowledgments xvii
about this book xx
about the authors xxiii
about the cover illustration xxiv
1
Ruby on Rails, the framework 1
1.1 What is Ruby on Rails? 2
Benefits 2

Common terms 3

Rails in the wild 4
1.2 Developing your first application 5
Installing Rails 5


Generating an application 6

Starting the
application 6

Scaffolding 7

Migrations 8

Viewing
and creating purchases 9

Validations 13

Showing off 14
Routing 15

Updating 16

Deleting 20
1.3 Summary 21
2
Testing saves your bacon 23
2.1 Test- and behavior-driven development 24
2.2 Test-driven development 24
Why test? 25

Writing your first test 25


Saving bacon 27
2.3 Behavior-driven development 28
RSpec 29

Cucumber 35
2.4 Summary 42
www.it-ebooks.info
CONTENTSviii
3
Developing a real Rails application 44
3.1 Application setup 45
The application story 45

Version control 47

The Gemfile
and generators 50

Database configuration 53

Applying a
stylesheet 54
3.2 First steps 55
Creating projects 55

RESTful routing 60

Committing
changes 72


Setting a page title 72

Validations 76
3.3 Summary 81
4
Oh CRUD! 83
4.1 Viewing projects 83
Writing a feature 84

The Factory Girl 85

Adding a link to
a project 86
4.2 Editing projects 88
The edit action 88

The update action 90
4.3 Deleting projects 91
Writing a feature 92

Adding a destroy action 92

Looking
for what isn’t there 93
4.4 Summary 97
5
Nested resources 99
5.1 Creating tickets 99
Nested routing helpers 100


Creating a tickets controller 101
Defining a has_many association 103

Creating tickets within a
project 104

Finding tickets scoped by project 105

Ticket
validations 106
5.2 Viewing tickets 108
Listing tickets 110

Culling tickets 111
5.3 Editing tickets 112
Adding the edit action 113

Adding the update action 114
5.4 Deleting tickets 115
5.5 Summary 116
6
Authentication and basic authorization 117
6.1 What Devise does 118
Installing Devise 118
www.it-ebooks.info
CONTENTS ix
6.2 User signup 121
6.3 Confirmation link sign-in 122
Testing email 122


Confirming confirmation 123
6.4 Form sign-in 126
6.5 Linking tickets to users 128
Attributing tickets to users 129

We broke something! 131
Fixing the Viewing Tickets feature 132

Fixing the Editing
Tickets feature 133

Fixing the Deleting Tickets feature 134
6.6 Summary 135
7
Basic access control 136
7.1 Projects can be created only by admins 137
7.2 Adding the admin field to the users table 138
7.3 Restricting actions to admins only 138
Fixing three more broken scenarios 143

Hiding the New Project
link 144

Hiding the edit and delete links 146
7.4 Namespace routing 148
7.5 Namespace-based CRUD 151
Adding a namespace root 151

The index action 152
The new action 153


The create action 154
7.6 Creating admin users 155
7.7 Editing users 157
The show action 158

The edit and update actions 159
7.8 Deleting users 161
Ensuring you can’t delete yourself 162
7.9 Summary 163
8
More authorization 164
8.1 Restricting read access 165
8.2 Restricting by scope 168
8.3 Fixing what you broke 172
Fixing Editing Projects 173

Fixing the four failing
features 173

One more thing 176

Fixing Signing Up 178
8.4 Blocking access to tickets 183
Locking out the bad guys 183
www.it-ebooks.info
CONTENTSx
8.5 Restricting write access 185
Rewriting a feature 185


Blocking creation 187

What is
CanCan? 188

Adding abilities 189
8.6 Restricting update access 190
No updating for you! 191

Authorizing editing 192
8.7 Restricting delete access 193
Enforcing destroy protection 193

Hiding links based on
permission 194
8.8 Assigning permissions 198
Viewing projects 198

And the rest 206
8.9 Seed data 209
8.10 Summary 212
9
File uploading 213
9.1 Attaching a file 214
A feature featuring files 214

Enter stage right, Paperclip 216
Using Paperclip 217
9.2 Attaching many files 220
Two more files 221


Using nested attributes 224
9.3 Serving files through a controller 226
Protecting files 227

Showing your assets 228

Public
assets 230

Privatizing assets 230
9.4 Using JavaScript 231
JavaScript testing 232

Introducing jQuery 233

Adding
more files with JavaScript 234

Responding to an asynchronous
request 235

Sending parameters for an asynchronous
request 237
9.5 Summary 241
10
Tracking state 243
10.1 Leaving a comment 244
Where’s the ticket? 245


The comment form 247
The comment model 247

The comments controller 249
10.2 Changing a ticket’s state 252
Creating the State model 253

Selecting states 255
Callbacks 257

Seeding states 259

Fixing creating
comments 261
www.it-ebooks.info
CONTENTS xi
10.3 Tracking changes 263
Ch-ch-changes 263

Another c-c-callback 264

Displaying
changes 265

Show me the page 266

Automatic escaping
saves your bacon 267

Styling states 268

10.4 Managing states 269
Adding additional states 270

Defining a default state 273
10.5 Locking down states 278
Hiding a select box 278

Bestowing changing state
permissions 280

Hacking a form 282

Ignoring a
parameter 283
10.6 Summary 285
11
Tagging 286
11.1 Creating tags 287
Creating tags feature 287

Using text_field_tag 288
Showing tags 288

Defining the tags association 289
The Tag model 289

Displaying a ticket’s tags 290
11.2 Adding more tags 292
Adding tags through a comment 292


Fixing the
CommentsController spec 294
11.3 Tag restriction 295
Testing tag restriction 295
Tags are allowed, for some 296
11.4 Deleting a tag 297
Testing tag deletion 298

Adding a link to delete the
tag 299

Actually removing a tag 302
11.5 Finding tags 303
Testing search 303

Searching by state with
Searcher 305

Searching by state 307

Search, but
without the search 309
11.6 Summary 310
12
Sending email 312
12.1 Sending ticket notifications 313
Automatically watching a ticket 314

Using observers 315
Defining the watchers association 316


Introducing Action
Mailer 318

An Action Mailer template 320

Delivering
HTML emails 322
www.it-ebooks.info
CONTENTSxii
12.2 Subscribing to updates 325
Testing comment subscription 325

Automatically adding a user
to a watchlist 327

Unsubscribing from ticket notifications 328
12.3 Real-world email 333
Testing real-world email 334

Configuring Action Mailer 336
Connecting to Gmail 337
12.4 Receiving emails 340
Setting a reply-to address 340

Receiving a reply 342
12.5 Summary 345
13
Designing an API 347
13.1 The projects API 349

Your first API 351

Serving an API 354

API
authentication 355

Error reporting 356

Serving
XML 358

Creating projects 360

Restricting access to only
admins 362

A single project 365

No project for you! 368
Updating a project 370

Exterminate! 372
13.2 Beginning the tickets API 374
13.3 Rate limiting 377
One request, two request, three request, four 377

No more,
thanks! 379


Back to zero 380
13.4 Versioning an API 381
Creating a new version 381
13.5 Summary 384
14
Deployment 385
14.1 Server setup 386
Setting up a server using VirtualBox 386

Installing the
base 388
14.2 RVM and Ruby 389
Installing RVM 389

Installing Ruby 390
14.3 Creating a user for the app 391
Key-based authentication 391

Disabling password
authentication 393
14.4 The database server 394
Creating a database and user 394

Ident authentication 395
www.it-ebooks.info
CONTENTS xiii
14.5 Deploy away! 395
Deploy keys 396

Configuring Capistrano 397


Setting up
the deploy environment 400

Deploying the application 401
Bundling gems 403

Choosing a database 405
14.6 Serving requests 407
Installing Passenger 408

An init script 410
14.7 Summary 410
15
Alternative authentication 412
15.1 How OAuth works 413
15.2 Twitter authentication 415
Setting up OmniAuth 415

Registering an application with
Twitter 416

Setting up an OmniAuth testing
environment 417

Testing Twitter sign-in 419
15.3 GitHub authentication 425
Registering and testing GitHub auth 425
15.4 Summary 433
16

Basic performance enhancements 434
16.1 Pagination 435
Introducing Kaminari 436

Paginating an interface 437
Paginating an API 443
16.2 Database query enhancements 444
Eager loading 445

Database indexes 446
16.3 Page and action caching 448
Caching a page 448

Caching an action 451

Cache
sweepers 454

Client-side caching 457

Caching page
fragments 460
16.4 Background workers 462
16.5 Summary 466
17
Engines 468
17.1 A brief history of engines 469
17.2 Why engines are useful 470
17.3 Brand-new engine 471
Creating an engine 471


The layout of an engine 472
Engine routing 476
www.it-ebooks.info
CONTENTSxiv
17.4 Setting up a testing environment 478
Removing Test::Unit 479

Installing RSpec and
Capybara 481
17.5 Writing your first engine feature 482
Your first Capybara test 483

Setting up routes 484

The
topics controller 485

The index action 485

The new
action 488

The create action 489

The show action 490
Showing an association count 492
17.6 Adding more posts to topics 493
17.7 Classes outside your control 497
Engine configuration 497


A fake User model 500
Authenticating topics 501

Adding authorship to topics 505
Post authentication 506

Showing the last post 509
17.8 Releasing as a gem 512
17.9 Integrating with an application 513
17.10 Summary 514
18
Rack-based applications 516
18.1 Building Rack applications 517
A basic Rack application 518
18.2 Building bigger Rack applications 522
You’re breaking up 522

Running a combined Rack
application 524
18.3 Mounting a Rack application with Rails 525
Mounting Heartbeat 526

Introducing Sinatra 527
The API, by Sinatra 528

Basic error checking 532
18.4 Middleware 533
Middleware in Rails 534


Investigating
ActionDispatch::Static 536

Crafting middleware 538
18.5 Summary 540
appendix A Why Rails? 541
appendix B Tidbits 546
index 551
www.it-ebooks.info
xv
preface
This book has been through quite the development process! It began in 2008 with
Michael Ivey, Yehuda Katz, and Ezra Zygmuntowicz and was called Merb in Action. Since
then it has changed name and hands a couple of times, winding up with people such as
James Cox and the great Mike Gunderloy, the latter of whom is probably most famous
for his work on Factsheet Five and many .NET books, not to mention being one of the
founding members of the RailsBridge () organization.
Then, somehow, I became involved with this book.
I received an email on a cold April morning in 2010 from Christina Rudloff at
Manning asking if I would have any interest in joining the project. I was exceptionally
excited! I had been writing short blog posts about Rails for years, and the idea of
focusing that effort into writing a book made me extremely happy. Long story short:
Yehuda Katz liked what he saw on my blog and wanted me to join the project. Working
with Yehuda has been brilliant. He’s got to be one of the smartest and most patient
people I have ever met.
Shortly after receiving that initial email from Christina, I talked with another per-
son from Manning, Michael Stephens, first via email and then very late at night over
the phone (we are on different continents) about the project. I worked out the initial
chapter layout, and I distinctly remember one thing that Michael asked me: “You
know what you’re getting yourself into, right?” I thought “Sure, I’ve written blog posts

before, how hard could it be?” and replied in much the same manner. How little did
I know!
Since then, I have learned a lot about the book-writing process. For starters, it
involves a lot more than just the two people and the publishing company on the front
www.it-ebooks.info
PREFACExvi
cover. It also takes a very long time to write a book. This book has been my life for the
past year and a bit. I’ve spent many weekends, mornings before work, and evenings
after work (and way too often, time even in my dreams) writing chapters for this book.
I’ve talked about it (perhaps too much) as well. It’s become such a running joke
among people I know that when I’m introduced, they ask, “Do you know he’s writing a
book?”
Writing is sometimes easy, but other times it can be a struggle to come up with any-
thing at all. There have been bad days, sure, but the good days outnumber those mas-
sively. The feeling of achievement you get when you finish a chapter, or even a section,
is awesome. Receiving positive feedback from people has been a huge boon to com-
pleting this book.
Now, in 2011, the book is finally done, and what an amazing feeling that is! I’d like
to think that it offers a unique perspective on developing a full Ruby on Rails applica-
tion from scratch in the same (or at least, similar) manner that people are developing
Rails applications at this time. It’s also the first book to cover the latest features of
Rails found in version 3.1.
RYAN BIGG
www.it-ebooks.info
xvii
acknowledgments
This has been an amazing process, full of amazing people. A large portion of this
book would not have been possible without the support of my employer, Mikel Lind-
saar, and company, RubyX, allowing me to take time off to write the book. The sup-
port of the community at large has also been enormous in helping me complete this

book. Winning the Ruby Hero award at RailsConf, partially due to my work on this
very book, was the highlight of my career so far. After I won the award, Mikel also pro-
vided me with a new laptop at no expense to replace my previous one that was three
years old. Bloody champion!
Of course, a lot of this wouldn’t have been as easy if it wasn’t for the Rails Core
Team’s valiant efforts on the ir maintenance of the framework over the years and their
constant focus on improving people’s lives on an almost daily basis. Also there are
Yehuda Katz, Carl Lerche, and André Arko to thank for their work on an important
part of developing not only Rails applications, but also Ruby libraries such as Bundler
and Thor. These people are my idols, and I love them dearly.
Through a Rails-based review system called Twist that I built myself over a single
day, I’ve collected more than 1,200 notes from people from around the world who
have been reviewing the book as I have been writing it. A special mention goes to the
three people who’ve left the most notes in Twist: Roy Hacker, Deryl Doucette, and
Peter Ley. An almost-as-special mention goes to the 33 other people who’ve also left
notes. Without your help, this book wouldn’t be half as brilliant as it is today.
Also thanks to Tim McEwan for the ideas for the engines chapter, Chris Darroch
for an initial read-through of the first chapters, and Rob Zolkos for helping with some
www.it-ebooks.info
ACKNOWLEDGMENTSxviii
gnarly ePub Ruby and XLST code. And yes, thanks to Andrew Snow for assisting with a
difficult moral problem in chapter 16 at Railscamp in June 2011.
In addition to those who’ve been leaving notes in Twist, there are the people at
Manning. First, thanks to Christina Rudloff for the initial contact and Michael Ste-
phens for the late-night chats and management of the process. Candace Gillhooley
and Nick Chase have also been enormously helpful.
Cynthia Kane, my development editor at Manning, is particularly special. Her job
was to tell me when I was doing things wrong, such as not segueing between sections
or making the text flow too fast, and to leave me notes such as “
FIGURE!!!” when I

needed an image to go along with the text. Our almost weekly catch-ups were well
worthwhile; it was great always having someone there, prodding me for more content
and talking through the process. Marjan Bace, fearless leader of Manning Publica-
tions, should also be credited for supporting this project for as long as it has been
around.
The production team at Manning, including Troy Mott, has been great throughout
this process too. The extreme focus they’ve shown in finishing this book is stunning. I
also need to mention the wonderful work by Doug Warren in the final technical
proofing of the book, as well as Manning’s copyeditors, who touched up basically
every single paragraph in the book.
Special thanks to the reviewers who took time out of their busy schedules to pro-
vide feedback on the manuscript at different stages during development. They
include Jason Rogers, Craig Smith, Emmanuel Asante, Chad Moone, Dr. Jamie P. Fin-
lay, Dave Nicolette, Grant Oladipo, Jean-Philippe Castro, Americo Savinon, Thomas
Athanas, Chris Kelly, Greg Vaughn, Pete Helgren, Joshua R Cronemeyer, Peter Melo,
Robby O’Connor, Philip Hallstrom, Curtis Miller, Patrick Peak, Anthony J. Topper,
Brian Rose, Daniel Bretoi, Wesley Moxam, Jon Agnes, and David Workman
Finally, my friends and family have been amazing throughout my entire life, all the
way from my parents—who supported my career choice in Ruby on Rails and techni-
cal writing, even though they paid for me to study Network Admin at
TAFE and always
told me that I should “get out the house more”—to my current housemate, who
accepts that we don’t see much of each other (or at least I think so). You’re all won-
derful people, and I hope now that the book is over I will see more of you. I would list
you all here if only it didn’t require this book to be printed in a multivolume series.
R
YAN BIGG
Rails 3 in Action is a long-time coming. To give you some perspective, the book was
originally called Merb in Action, and it managed a perpetual beta through the Merb
merge, the release of Rails 3.0, and is finally ready just in time for Rails 3.1.

I can say with confidence that Rails 3 in Action would not exist without the hard,
tireless work of Ryan Bigg. It was Ryan’s idea to focus the book around real-world test-
ing from the ground up, and it makes Rails 3 in Action the first book for Rails practitio-
ners that teaches Rails the way professional Rails developers do it.
www.it-ebooks.info
ACKNOWLEDGMENTS xix
Since we merged Merb with Rails, I have had the benefit of not insignificant sup-
port from friends and family, who helped keep me on course in the long process that
eventually delivered Rails 3.0. I want to especially call out Aaron Patterson, José Valim,
Santiago Pastorino, and Xavier Noria, who stepped up and brought life back to a com-
munity that was starting to show signs of age by the time Rails 2.3 hit the shelves. And
Carl Lerche, who helped me keep focus on doing things right, even when it was
tempting not to.
Finally, I would be remiss if I didn't thank my wife, Leah, who has been there for
me through the amazing trajectory of my development career, through good times
and bad. Without her, I would have given up long ago.
YEHUDA KATZ
www.it-ebooks.info
xx
about this book
Ruby on Rails is a leading web application framework built on top of the fantastic
Ruby programming language. Both the language and the framework place an
extreme emphasis on having a principle of least surprise and getting out of the way of
the developers using it.
Ruby on Rails has been growing at a rapid pace, with large internet companies
such as Yellow Pages and Groupon using it for their core functionality. With the latest
release of Rails, version 3.1, comes a set of changes that improve the already brilliant
framework that has been constructed over the past seven years. The fantastic commu-
nity around the framework has also been growing at a similar pace.
This book is designed to take you through developing a full-featured Rails applica-

tion from step one, showing you exactly how professionals in the real world are devel-
oping applications right now.
Who should read this book
This book is primarily for those who are looking to begin working with the Ruby on
Rails framework and who have some prior experience with Ruby, although that is not
entirely necessary.
Later chapters, such as chapter 13, “Designing an API,” chapter 17, “Engines,” and
chapter 18, “Rack-based applications,” delve into more advanced topics, so these chap-
ters are suitable for people who already have a foundation with Rails and are looking
to expand their skillset a little further.
If you’re looking for a book that teaches you the same practices that are used in
the real world, then this is the book you are looking for.
www.it-ebooks.info
ABOUT THIS BOOK xxi
Roadmap
Chapter 1 introduces the Ruby on Rails framework and begins to show how you can
develop the beginnings of an application.
Chapter 2 shows off test-driven development and behavior-driven development,
which are two core concepts in this book and for developing Rails applications. By
testing the code you write, you can be assured that it’s always working that way.
Chapters 3 and 4 discuss the application you develop in this book—a project-man-
agement app of sorts—and delve into the core concepts of a Rails application. They
also look at developing the first core features of your application.
Chapter 5 begins an introduction to nested resources, building on top of the fea-
tures developed in the previous two chapters.
Chapter 6 introduces authentication, requiring users to sign in to the application
before they can perform certain tasks.
Chapter 7 builds on the work in chapter 6 by adding new areas of the application
that are accessible only to users with a certain flag set in the database. You also use
namespaces for the first time.

Chapter 8 builds on the basic authorization created in chapter 7, fleshing it out
into something neater and more scalable.
In chapter 9, you learn about file uploading using the Paperclip gem. In this chap-
ter you also learn about testing parts of your application that use JavaScript and about
CoffeeScript, a neater language that compiles down to JavaScript.
Chapter 10 builds not one but two new features for the application, adding the
ability to comment on a ticket as well as track the ticket’s lifecycle through varying
states.
In chapter 11, you add a feature that lets users assign tags to tickets so they can be
easily grouped. You also add a feature to allow users to search for tickets matching a
certain state or tag, or both.
Chapter 12 begins our foray into dealing with email in a Rails application. You’ll
see not only how to send email but also how to receive messages and parse them into
meaningful data in your application.
Chapter 13 involves creating an
API for the project resources in an application
that provide other applications with a standardized way to access your application’s
data. We also look at token-based authentication and how to create multiple versions
of an API.
In chapter 14, you deploy the application to an Ubuntu box and set it up to act like
a normal web server using a RubyGem called Passenger and a web server called nginx.
In chapter 15, you create a “nice to have” feature: the ability to sign up or sign in
using either Twitter or GitHub. When this is complete, people are no longer required
to provide you with an email and password when they sign up; instead, they can use
GitHub and Twitter as authentication providers.
www.it-ebooks.info
ABOUT THIS BOOKxxii
By chapter 16, your application is all grown up and needs to handle any kind of
performance issues it encounters. We cover basic performance enhancements, such
as pagination, database indexing, and page and fragment caching.

Chapter 17 introduces a new feature for Rails 3: engines. You develop one of your
own from scratch—a forum system—and then integrate it with the existing application.
Chapter 18 delves into the depths of Rack, explaining how Rack applications are
made and can be tied into Rails. The chapter also explains, and contains examples of,
middleware being used in Rails.
Code conventions and downloads
Code conventions in the book follow the style of other Manning books in the In Action
series. All code in listings and in text appears in
a

monospaced

font

like

this
to sepa-
rate it from ordinary text. In some cases, the original source code has been reformat-
ted to fit on the pages. In general, the original code was written with page-width
limitations in mind, but sometimes you may find a slight formatting difference
between the code in the book and that provided in the source download. In a few rare
cases, where long lines could not be reformatted without changing their meaning, the
book listings contain line-continuation markers. Code annotations accompany many
of the listings, highlighting important concepts. In many cases, numbered bullets link
to explanations that follow in the text.
Source code for all the working examples in this book is available for download
from the publisher’s website at www.manning.com/Rails3inAction.
Author Online
The purchase of Rails 3 in Action includes free access to a private forum run by Man-

ning Publications where you can make comments about the book, ask technical ques-
tions, and receive help from the authors and other users. To access and subscribe to
the forum, point your browser to www.manning.com/Rails3inAction, and click the
Author Online link. This page provides information on how to get on the forum once
you are registered, what kind of help is available, and the rules of conduct in the
forum.
Manning’s commitment to our readers is to provide a venue where a meaningful
dialogue between individual readers and between readers and the authors can take
place. It’s not a commitment to any specific amount of participation on the part of the
authors, whose contribution to the book’s forum remains voluntary (and unpaid). We
suggest you try asking the authors some challenging questions, lest their interest stray!
The Author Online forum and the archives of previous discussions will be accessi-
ble from the publisher’s website as long as the book is in print.
www.it-ebooks.info
xxiii
about the authors
RYAN BIGG has been developing Ruby on Rails since version 1.2 and can be found
helping out the community by answering questions on IRC or StackOverflow or writ-
ing documentation. He currently works for a web consultancy based in Sydney called
RubyX.
YEHUDA KATZ is well known not only for his work on this third version of Ruby on
Rails, but also for other web-related projects such as jQuery, Bundler, Merb, and
SproutCore. He currently works for Strobe in San Francisco as a lead developer on
SproutCore and is the coauthor of Manning’s jQuery in Action, Second Edition.
www.it-ebooks.info
xxiv
about the cover illustration
The figure on the cover of Rails 3 in Action is captioned “A Soldier.” The illustration is
taken from a nineteenth-century edition of Sylvain Maréchal’s four-volume compen-
dium of regional and military dress customs published in France. Each illustration is

finely drawn and colored by hand. The rich variety of Maréchal’s collection reminds
us vividly of how culturally apart the world’s towns and regions were just 200 years ago.
Isolated from each other, people spoke different dialects and languages. In the streets
or in the countryside, it was easy to identify where they lived and what their trade or
station in life was just by their dress.
Dress codes have changed since then and the diversity by region, so rich at the
time, has faded away. It is now hard to tell apart the inhabitants of different conti-
nents, let alone different towns or regions. Perhaps we have traded cultural diversity
for a more varied personal life—certainly for a more varied and fast-paced technolog-
ical life.
At a time when it is hard to tell one computer book from another, Manning cele-
brates the inventiveness and initiative of the computer business with book covers
based on the rich diversity of regional life of two centuries ago, brought back to life by
Maréchal’s pictures.
www.it-ebooks.info

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×