100% found this document useful (2 votes)
26 views

Agile Web Development with Rails 4th edition Beta 10 version Sam Rubydownload

The document promotes various ebooks and textbooks available for download at ebookultra.com, focusing on Ruby on Rails development. It highlights the 'Agile Web Development with Rails 4th edition Beta' by Sam Ruby, along with other related titles. The document also mentions that the beta version is still under development and invites feedback from readers.

Uploaded by

yarpazjileni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
26 views

Agile Web Development with Rails 4th edition Beta 10 version Sam Rubydownload

The document promotes various ebooks and textbooks available for download at ebookultra.com, focusing on Ruby on Rails development. It highlights the 'Agile Web Development with Rails 4th edition Beta' by Sam Ruby, along with other related titles. The document also mentions that the beta version is still under development and invites feedback from readers.

Uploaded by

yarpazjileni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Download the full version and explore a variety of ebooks

or textbooks at https://ebookultra.com

Agile Web Development with Rails 4th edition Beta


10 version Sam Ruby

_____ Tap the link below to start your download _____

https://ebookultra.com/download/agile-web-development-with-
rails-4th-edition-beta-10-version-sam-ruby/

Find ebooks or textbooks at ebookultra.com today!


We have selected some products that you may be interested in
Click the link to download now or visit ebookultra.com
for more options!.

Agile Web Development with Rails 5 1st Edition Sam Ruby

https://ebookultra.com/download/agile-web-development-with-
rails-5-1st-edition-sam-ruby/

Ruby on Rails Tutorial Learn Web Development with Rails


3rd Edition Michael Hartl

https://ebookultra.com/download/ruby-on-rails-tutorial-learn-web-
development-with-rails-3rd-edition-michael-hartl/

Build Your Own Ruby on Rails Web Applications 1st Edition


Patrick Lenz

https://ebookultra.com/download/build-your-own-ruby-on-rails-web-
applications-1st-edition-patrick-lenz/

Practical Reporting with Ruby and Rails 1st Edition David


Berube

https://ebookultra.com/download/practical-reporting-with-ruby-and-
rails-1st-edition-david-berube/
RailsSpace Building a Social Networking Website with Ruby
on Rails Addison Wesley Professional Ruby Series Hartl

https://ebookultra.com/download/railsspace-building-a-social-
networking-website-with-ruby-on-rails-addison-wesley-professional-
ruby-series-hartl/

Practical JRuby on Rails Web 2 0 projects bringing Ruby on


Rails to the Java platform 1st Edition Ola Bini

https://ebookultra.com/download/practical-jruby-on-rails-
web-2-0-projects-bringing-ruby-on-rails-to-the-java-platform-1st-
edition-ola-bini/

Pro Active Record Databases with Ruby and Rails 1st


Edition Kevin Marshall

https://ebookultra.com/download/pro-active-record-databases-with-ruby-
and-rails-1st-edition-kevin-marshall/

Ruby on Rails Background Jobs with Sidekiq 1 / converted


Edition David B. Copeland

https://ebookultra.com/download/ruby-on-rails-background-jobs-with-
sidekiq-1-converted-edition-david-b-copeland/

Ruby on Rails For Dummies 1st Edition Burd

https://ebookultra.com/download/ruby-on-rails-for-dummies-1st-edition-
burd/
Agile Web Development with Rails 4th edition Beta 10
version Sam Ruby Digital Instant Download
Author(s): Sam Ruby, Dave Thomas, David Heinemeier Hansson
ISBN(s): 9781934356548, 1934356549
Edition: Fourth Edition
File Details: PDF, 14.89 MB
Year: 2011
Language: english
Prepared exclusively for Anton Fonarev
Beta
Book
Agile publishing for agile developers

Under Construction The book you’re reading is still under development. As


part of our Beta book program, we’re releasing this copy well before a normal
book would be released. That way you’re able to get this content a couple of
months before it’s available in finished form, and we’ll get feedback to make
the book even better. The idea is that everyone wins!

Be warned. The book has not had a full technical edit, so it will contain
errors. It has not been copyedited, so it will be full of typos and other weird-
ness. And there’s been no effort spent doing layout, so you’ll find bad page
breaks, over-long lines with little black rectangles, incorrect hyphenations,
and all the other ugly things that you wouldn’t expect to see in a finished
book. We can’t be held liable if you use this book to try to create a spiffy
application and you somehow end up with a strangely shaped farm imple-
ment instead. Despite all this, we think you’ll enjoy it!

Download Updates Throughout this process you’ll be able to download


updated ebooks from your account on http://pragprog.com. When the book
is finally ready, you’ll get the final version (and subsequent updates) from the
same address.

Send us your feedback In the meantime, we’d appreciate you sending us


your feedback on this book at http://pragprog.com/titles/rails4/errata, or by using
the links at the bottom of each page.

Thank you for being part of the Pragmatic community!

Andy & Dave

Prepared exclusively for Anton Fonarev


Agile Web Development with Rails
Fourth Edition

Sam Ruby
Dave Thomas
David Heinemeier Hansson

Leon Breedt
with
Mike Clark
James Duncan Davidson
Justin Gehtland
Andreas Schwarz

The Pragmatic Bookshelf


Raleigh, North Carolina Dallas, Texas

Prepared exclusively for Anton Fonarev


Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and The Pragmatic Program-
mers, LLC was aware of a trademark claim, the designations have been printed in initial capital
letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Program-
ming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers,
LLC.

Every precaution was taken in the preparation of this book. However, the publisher assumes no
responsibility for errors or omissions, or for damages that may result from the use of information
(including program listings) contained herein.

Our Pragmatic courses, workshops, and other products can help you and your team create better
software and have more fun. For more information, as well as the latest Pragmatic titles, please
visit us at http://www.pragprog.com.

Copyright © 2010 The Pragmatic Programmers LLC.

All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any
form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the
prior consent of the publisher.

Printed in the United States of America.

ISBN-10: 1-934356-54-9
ISBN-13: 978-1-934356-54-8
Printed on acid-free paper.
B10.0 printing, October 28, 2010
Version: 2010-10-28

Prepared exclusively for Anton Fonarev


Contents
Changes in the Beta Releases 10
Beta 10—October 28 . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Beta 9—October 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Beta 8—September 9 . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Beta 7—August 25 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Beta 6—July 27 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Beta 5—June 28 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Beta 4—May 26 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Beta 3—May 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Beta 2—May 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Preface to the Fourth Edition 14

Acknowledgements 16

Introduction 18
Rails Simply Feels Right . . . . . . . . . . . . . . . . . . . . . . . . . 18
Rails Is Agile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Who This Book Is For . . . . . . . . . . . . . . . . . . . . . . . . . . 21
How To Read This Book . . . . . . . . . . . . . . . . . . . . . . . . . 21

Part I—Getting Started 25

1 Installing Rails 26
1.1 Installing on Windows . . . . . . . . . . . . . . . . . . . . . . 26
1.2 Installing on Mac OS X . . . . . . . . . . . . . . . . . . . . . 28
1.3 Installing on Linux . . . . . . . . . . . . . . . . . . . . . . . . 29
1.4 Choosing a Rails Version . . . . . . . . . . . . . . . . . . . . 30
1.5 Setting Up Your Development Environment . . . . . . . . . 31
1.6 Rails and Databases . . . . . . . . . . . . . . . . . . . . . . . 35
1.7 What We Just Did . . . . . . . . . . . . . . . . . . . . . . . . 36

Prepared exclusively for Anton Fonarev


CONTENTS 6

2 Instant Gratification 37
2.1 Creating a New Application . . . . . . . . . . . . . . . . . . . 37
2.2 Hello, Rails! . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.3 Linking Pages Together . . . . . . . . . . . . . . . . . . . . . 46
2.4 What We Just Did . . . . . . . . . . . . . . . . . . . . . . . . 48

3 The Architecture of Rails Applications 50


3.1 Models, Views, and Controllers . . . . . . . . . . . . . . . . 50
3.2 Rails Model Support . . . . . . . . . . . . . . . . . . . . . . . 53
3.3 Action Pack: The View and Controller . . . . . . . . . . . . 55

4 Introduction to Ruby 57
4.1 Ruby Is an Object-Oriented Language . . . . . . . . . . . . 57
4.2 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.3 Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.4 Organizing Structures . . . . . . . . . . . . . . . . . . . . . . 65
4.5 Marshaling Objects . . . . . . . . . . . . . . . . . . . . . . . 68
4.6 Pulling It All Together . . . . . . . . . . . . . . . . . . . . . . 68
4.7 Ruby Idioms . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Part II—Building an Application 72

5 The Depot Application 73


5.1 Incremental Development . . . . . . . . . . . . . . . . . . . . 73
5.2 What Depot Does . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.3 Let’s Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

6 Task A: Creating the Application 80


6.1 Iteration A1: Creating the Products Maintenance Applica-
tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.2 Iteration A2: Making Prettier Listings . . . . . . . . . . . . . 87

7 Task B: Validation and Unit Testing 94


7.1 Iteration B1: Validating! . . . . . . . . . . . . . . . . . . . . . 94
7.2 Iteration B2: Unit Testing of Models . . . . . . . . . . . . . 99

8 Task C: Catalog Display 108


8.1 Iteration C1: Creating the Catalog Listing . . . . . . . . . . 108
8.2 Iteration C2: Adding a Page Layout . . . . . . . . . . . . . . 111
8.3 Iteration C3: Using a Helper to Format the Price . . . . . . 115
8.4 Iteration C4: Functional Testing of Controllers . . . . . . . 115

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
CONTENTS 7

9 Task D: Cart Creation 120


9.1 Iteration D1: Finding a Cart . . . . . . . . . . . . . . . . . . 120
9.2 Iteration D2: Connecting Products to Carts . . . . . . . . . 121
9.3 Iteration D3: Adding a Button . . . . . . . . . . . . . . . . . 123

10 Task E: A Smarter Cart 129


10.1 Iteration E1: Creating a Smarter Cart . . . . . . . . . . . . 129
10.2 Iteration E2: Handling Errors . . . . . . . . . . . . . . . . . 134
10.3 Iteration E3: Finishing the Cart . . . . . . . . . . . . . . . . 136

11 Task F: Add a Dash of Ajax 142


11.1 Iteration F1: Moving the Cart . . . . . . . . . . . . . . . . . 143
11.2 Iteration F2: Creating an Ajax-Based Cart . . . . . . . . . . 148
11.3 Iteration F3: Highlighting Changes . . . . . . . . . . . . . . 151
11.4 Iteration F4: Hiding an Empty Cart . . . . . . . . . . . . . . 153
11.5 Testing Ajax changes . . . . . . . . . . . . . . . . . . . . . . 156

12 Task G: Check Out! 161


12.1 Iteration G1: Capturing an Order . . . . . . . . . . . . . . . 161
12.2 Iteration G2: Atom Feeds . . . . . . . . . . . . . . . . . . . . 175
12.3 Iteration G3: Pagination . . . . . . . . . . . . . . . . . . . . . 179

13 Task H: Sending Mail 184


13.1 Iteration H1: Sending Confirmation E-mails . . . . . . . . . 184
13.2 Iteration H2: Integration Testing of Applications . . . . . . 191

14 Task I: Logging In 197


14.1 Iteration I1: Adding Users . . . . . . . . . . . . . . . . . . . 197
14.2 Iteration I2: Authenticating Users . . . . . . . . . . . . . . . 206
14.3 Iteration I3: Limiting Access . . . . . . . . . . . . . . . . . . 211
14.4 Iteration I4: Adding a Sidebar, More Administration . . . . 214

15 Task J: Internationalization 219


15.1 Iteration J1: Selecting the locale . . . . . . . . . . . . . . . . 220
15.2 Iteration J2: Translating the Store Front . . . . . . . . . . . 222
15.3 Iteration J3: Translating Checkout . . . . . . . . . . . . . . 229
15.4 Iteration J4: Add a Locale Switcher . . . . . . . . . . . . . . 235

16 Task K: Deployment and Production 239


16.1 Iteration K1: Deploying with Phusion Passenger and MySQL 241
16.2 Iteration K2: Deploying Remotely with Capistrano . . . . . 246
16.3 Iteration K3: Checking Up on a Deployed Application . . . 252

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
CONTENTS 8

17 Depot Retrospective 256


17.1 Rails Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . 256
17.2 Documenting What We Have Done . . . . . . . . . . . . . . 259

Part III—Rails In Depth 261

18 Finding Your Way Around Rails 262


18.1 Where things go . . . . . . . . . . . . . . . . . . . . . . . . . 262
18.2 Naming Conventions . . . . . . . . . . . . . . . . . . . . . . 270

19 Active Record 275


19.1 Defining your Data . . . . . . . . . . . . . . . . . . . . . . . . 275
19.2 Locating and Traversing Records . . . . . . . . . . . . . . . 280
19.3 Creating, Reading, Updating, and Deleting (CRUD) . . . . 283
19.4 Participating in the Monitoring Process . . . . . . . . . . . 299
19.5 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . 306

20 Action Dispatch and Action Controller 311


20.1 Dispatching Requests to Controllers . . . . . . . . . . . . . 311
20.2 Processing of Requests . . . . . . . . . . . . . . . . . . . . . 322
20.3 Objects and operations that span requests . . . . . . . . . 333

21 Action View 343


21.1 Using Templates . . . . . . . . . . . . . . . . . . . . . . . . . 343
21.2 Form Helpers . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
21.3 Processing Forms . . . . . . . . . . . . . . . . . . . . . . . . 348
21.4 Uploading Files to Rails Applications . . . . . . . . . . . . . 350
21.5 Creating Your Own Helpers . . . . . . . . . . . . . . . . . . . 353
21.6 Reducing Maintenance with Layouts and Partials . . . . . 360

22 Caching 369
22.1 Page Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
22.2 Expiring Pages . . . . . . . . . . . . . . . . . . . . . . . . . . 372
22.3 Fragment Caching . . . . . . . . . . . . . . . . . . . . . . . . 378

23 Migrations 384
23.1 Creating and Running Migrations . . . . . . . . . . . . . . . 384
23.2 Anatomy of a Migration . . . . . . . . . . . . . . . . . . . . . 387
23.3 Managing Tables . . . . . . . . . . . . . . . . . . . . . . . . . 391
23.4 Advanced Migrations . . . . . . . . . . . . . . . . . . . . . . 395
23.5 When Migrations Go Bad . . . . . . . . . . . . . . . . . . . . 400
23.6 Schema Manipulation Outside Migrations . . . . . . . . . . 401

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
CONTENTS 9

24 Non-Browser Applications 403


24.1 A Standalone Application Using Active Record . . . . . . . 403
24.2 A Library Function Using Active Support . . . . . . . . . . 404
24.3 A Remote Application Using Active Resource . . . . . . . . 409

25 Rails’ Dependencies 415


25.1 Generating XML with Builder . . . . . . . . . . . . . . . . . 415
25.2 Generating HTML with ERb . . . . . . . . . . . . . . . . . . 417
25.3 Managing Dependencies with Bundler . . . . . . . . . . . . 419
25.4 Interfacing with the web server with Rack . . . . . . . . . . 421
25.5 Automating Tasks with Rake . . . . . . . . . . . . . . . . . . 425
25.6 Survey of Rails’ Dependendencies . . . . . . . . . . . . . . . 426

26 Rails Plugins 430


26.1 Credit Card Processing with Active Merchant . . . . . . . . 430
26.2 Saving Bandwidth with Asset Packager . . . . . . . . . . . 432
26.3 Beautifying our Markup with Haml . . . . . . . . . . . . . . 434
26.4 Write Less and Do More with JQuery . . . . . . . . . . . . . 436
26.5 Finding more at RailsPlugin.org . . . . . . . . . . . . . . . . 439

27 Where to Go From Here 442

A Bibliography 444

Index 445

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
Changes in the Beta Releases
Beta 10—October 28
This beta introduces a chapter on plugins and completes the first draft. Plug-
ins are not merely an afterthought or an advanced feature of Rails, with Rails
3.0 it is a fully architected way to augment or even replace base Rails func-
tionality.

This also completes the first draft. If you spot something missing, now would
be an excellent time to report it via the forums or via an errata. After a few
weeks of addressing comments it will be onto production where formatting
and typographical and indexing glitches will be resolved.

This draft has also been tested against the Rails 3.0.1 release. No changes
were needed to make the code in this book work against that release.

Beta 9—October 6
With this beta comes a new chapter on Rails’ dependencies. Understanding
these dependencies are as important as understanding Rails itself. Introducing
this chapter has produced a minor shifting of content: some text that originally
was present in the rather large chapter on Action View has moved into this one.
Additional shifts are expected in the next beta: all such will be noted here.

While running with edge rails directly from git is not recommended at this
time, those that do run such may spot that csrf_meta_tag has been renamed to
csrf_meta_tags in that release. This does not affect any scenario in the book.

As always, thanks for all of the wonderful feedback via the errata, forums, and
other venues. At this time I would like to specifically thank Leonel S, Martin
Zoller, and Jim Puls.

Beta 8—September 9
Rails 3.0 final has shipped! Even better news: no API changes that affect the
book were introduced in the process. In one case, namely in the use of an
Action View helper from a standalone library, you will want to be using the

Prepared exclusively for Anton Fonarev


B ETA 7—A UGUST 25 11

final release instead of any previous beta or release candidate, so please do


upgrade now if you haven’t already.

New with this beta are three new chapters completing the coverage of the
externals of Rails. Caching covers how to effectively optimize your applica-
tion by eliminating the overhead of re-computing results that rarely change.
Migrations covers how to maintain your schemas. And finally, Non-Browser
Applications shows you how to access some or all of Rails functions either
locally or remotely.

As we enter into the home stretch, your feedback becomes all the more impor-
tant. There is an Report Erratum link at the bottom right of every page. Use it
when you spot something, even if you aren’t sure! If you would like to start a
discussion, the forum is a better place for that.

Beta 7—August 25
We have a new release candidate of Rails, as well as an official release of Ruby
1.9.2. I’m pleased to report that once again, no changes were made to any Rails
API that affect the book. Furthermore, the regression that in the first release
candidate which broke the ability to build the guides has been addressed.

New with this beta is a chapter on Action View, which covers templates, helpers,
layouts, and partials. At this point, all three parts of the Model/View/Controller
architecture are covered. Next up will be a chapter on accessing Rails applica-
tions from outside of a web server, either directly via APIs or as a web service.

As always, thanks for all of the wonderful feedback via the errata, forums, and
other venues. At this time I would like to specifically thank Kim Shrier, Don
Smith, mltsy, and Jason Catena.

Beta 6—July 27
The big news is that the release candidate for Rails has officially shipped. The
better news is that no API changes were made to Rails that affect the book.
Hopefully at this point releases of Rails will be made more quickly, and the API
will remain stable.

New with this beta is a chapter on Action Dispatch and Action Controller,
which covers both dispatching of requests to controllers, as well as controllers
themselves. At this point, two of the three parts on the Model/View/Controller
architecture are complete. Next up will be a chapter on Views.

Once again, thanks for all of the wonderful feedback via the errata, forums,
and other venues – keep it coming!

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
B ETA 5—J UNE 28 12

Beta 5—June 28
As I write this, the release candidate which was originally due on June 8th has
still not shipped, and we have decided to release a beta anyway. At the current
time, the contents of the book work with beta 4 and with the latest version of
Rails from github, but things could change between now and when the release
candidate ships.

The changes to Rails that affected this book in beta 4 were the requirement
to specify the keyword ’new’ when creating a new application with the ’rails’
command, and the fact that Rails 3.0 no longer works on Ruby 1.9.1. Ruby
1.9.2 preview 3, however, has come out and Rails 3.0 works just fine on it.
This beta has been updated to reflect these changes.

This beta also adds a chapter dedicated to Active Record, a topic which covered
three chapters in edition 3. The content has been updated to reflect Rails 3
APIs, and in particular ARel functionality. The content has been streamlined
to focus only on APIs that everybody needs to know, as well as content that
was adequately covered in Part II. It also reads less like a reference manual,
and more like a guide. Feedback welcome. In particular, please let me know if
something you feel is essential was not covered.

Again, thanks for all of the excellent errata. At this point, we are up to over
300 errata comments from over 80 individuals. I’d like to specifically thank
Seth Arnold, David Hadley, Will Bowlin, Victor Marius Costan, Kristian Riiber
Mandrup, Joe Straitiff, and Andy Brice.

Beta 4—May 26
This beta adds two chapters. The first recaps what was learned in part 2:
model, view, controller, configuration, testing, and deployment. It then contin-
ues with an explanation on how to generate documentation for your applica-
tion.

Chapter 18 is also new with this beta: it goes directory by directory through
your Rails application, describing what goes into each. You will see how to
generate documentation for Rails itself, how to build a Rake task, more infor-
mation on configuration options and naming conventions. This all sets the
stage for the chapters that follow.

The Rails team is in the process of deprecating config.log_path, but at the


present time has not settled on its replacement. Furthermore this property
is broken in Rails 3 beta 3. What you see in Section 16.3, Dealing with Log
Files, on page 253 reflects what currently works, which may not necessarily
be what will be supported in the final release.

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
B ETA 3—M AY 11 13

Beta 3—May 11
This beta adds a deployment chapter which takes you through the installation,
configuration, and usage of a number of tools: Apache, Capistrano, MySQL,
and Passenger; as well as (mildly) deeper usage of Git and Bundler.

There’s not been another beta of Rails yet, so this is just a FYI at this point,
but usage of {{name}} syntax in i18n strings will be deprecated; the preferred
syntax is now %{name}.

As always thanks for all of the wonderful feedback via the errata, forums, and
other venues – keep it coming!

Beta 2—May 3
Thanks for all of the excellent feedback. To date we’ve gotten over 100 com-
ments from over 30 individuals. Special thanks go out to Trung LE, David
Hadley, Manuel E Vidaurre Arenas, Wayne Conrad, and Steve Nicholson. A lot
of the changes you’ll see in this second beta are the result of this input. Please
keep it up, as every comment helps us make this book better!

This new release adds coverage of sending mail and integration testing in the
new chapter “Task H: Sending Mail.” You’ll learn how to send mail, how to
function test mail, and how to integration test an end-to-end scenario span-
ning adding a product to a cart to the sending of a confirmation email.

Only one change to Rails affects the book this go around: Rails will be changing
the way that I18N and HTML safe strings interact. The text in the book has
been partially updated to reflect the new direction, but will continue to work
with Beta 3.

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
Preface to the Fourth Edition
When Dave asked me to join as a coauthor of the third edition of this book,
I was thrilled. After all, it was from the first printing of the first edition of
this book that I had learned Rails. Dave and I also have much in common.
Although he prefers Emacs and Mac OS X and my preferences tend toward Vim
and Ubuntu, we both share a love for the command line and getting our fin-
gers dirty with code—starting with tangible examples before diving into heavy
theory.

Since the time the third edition was published (and, in fact, since the first, sec-
ond and third editions), much has changed. Rails is in the process of being sig-
nificantly refactored, mostly internally. A number of features that were used in
previous examples have been initially deprecated and subsequently removed.
New features have been added, and much experience has been obtained as to
what the best practices are for using Rails. Rails now also works on Ruby 1.9,
and each of the examples have been tested with Ruby 1.8.7 and Ruby 1.9.2.

Additionally, Rails has exploded from being a popular framework to an active


and vibrant ecosystem, complete with many popular plugins and deep inte-
gration into third party tools. In the process, Rails has become mainstream,
attracting a more diverse set of developers to the framework.

This has led to a reorganization of the book. Many newcomers to Rails have
not had the pleasure of being introduced to Ruby, so this section has been
promoted from an appendix to a chapter in the first section. We follow this
section with a step-by-step walk through of building a real application, which
has been updated and streamlined to focus on current best practices. But the
biggest change is in the final section: as it is no longer practical to cover the
entire ecosystem of Rails given both its breadth and rate of change, what this
section is now focused on is to provide an overall perspective of the landscape,
enabling you, the reader, to know what to look for and where to find plug-
ins and related tools to address common needs that go far beyond what the
framework itself contains.

Prepared exclusively for Anton Fonarev


P REFACE TO THE F OUR TH E DITION 15

In short, this book needed to adapt. Once again.

Sam Ruby
April 2010

Report erratum
Prepared exclusively for Anton Fonarev this copy is (B10.0 printing, October 28, 2010)
Exploring the Variety of Random
Documents with Different Content
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like