SlideShare a Scribd company logo
Learning Rails 3 Rails from the Outside In 1st
Edition Simon St. Laurent download
https://ebookname.com/product/learning-rails-3-rails-from-the-
outside-in-1st-edition-simon-st-laurent/
Get Instant Ebook Downloads – Browse at https://ebookname.com
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...
Rails Recipes Rails 3 Edition Chad Fowler
https://ebookname.com/product/rails-recipes-rails-3-edition-chad-
fowler/
Rails 4 in Action Revised Edition of Rails 3 in Action
Ryan Bigg
https://ebookname.com/product/rails-4-in-action-revised-edition-
of-rails-3-in-action-ryan-bigg/
Introducing Elixir Getting Started in Functional
Programming 2nd Edition Simon St. Laurent
https://ebookname.com/product/introducing-elixir-getting-started-
in-functional-programming-2nd-edition-simon-st-laurent/
Carbon Nanotubes and Related Structures Peter J. F.
Harris
https://ebookname.com/product/carbon-nanotubes-and-related-
structures-peter-j-f-harris/
Ethernet Networks Design Implementation Operation
Management 4th Edition Gilbert Held
https://ebookname.com/product/ethernet-networks-design-
implementation-operation-management-4th-edition-gilbert-held/
The Language of Psychoanalysis First Edition Laplanche
https://ebookname.com/product/the-language-of-psychoanalysis-
first-edition-laplanche/
Somebody Better Page Turners Level 1 1st Edition Julian
Thomlinson
https://ebookname.com/product/somebody-better-page-turners-
level-1-1st-edition-julian-thomlinson/
Death by a Thousand Cuts The Fight over Taxing
Inherited Wealth 1st Edition Michael J. Graetz
https://ebookname.com/product/death-by-a-thousand-cuts-the-fight-
over-taxing-inherited-wealth-1st-edition-michael-j-graetz/
Regret Developmental Cultural and Clinical Realms 1st
Edition Salman Akhtar
https://ebookname.com/product/regret-developmental-cultural-and-
clinical-realms-1st-edition-salman-akhtar/
China Building an Innovative Economy 1st Edition
Celeste Varum
https://ebookname.com/product/china-building-an-innovative-
economy-1st-edition-celeste-varum/
Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent
Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent
Learning Rails 3
Simon St.Laurent, Edd Dumbill, and Eric J. Gruber
Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo
Learning Rails 3
by Simon St.Laurent, Edd Dumbill, and Eric J. Gruber
Copyright © 2012 Simon St.Laurent, Edd Dumbill, Eric J. Gruber. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com.
Editor: Simon St.Laurent
Production Editor: Iris Febres
Proofreader: Jasmine Perez
Indexer: Lucie Haskins
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrators: Robert Romano, Rebecca Demarest,
and Jessamyn Read
July 2012: First Edition.
Revision History for the First Edition:
2012-07-11 First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449309336 for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Learning Rails 3, the image of the tarpans, and related trade dress are trademarks
of O’Reilly Media, Inc.
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 O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-30933-6
[M]
1342467902
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
1. Starting Up Ruby on Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
If You Run Windows, You’re Lucky 2
Getting Started at the Command Line 3
Starting Up Rails 8
Test Your Knowledge 9
Quiz 9
Answers 9
2. Rails on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Creating Your Own View 11
What Are All Those Folders? 14
Adding Some Data 16
How Hello World Works 18
Adding Logic to the View 20
Test Your Knowledge 22
Quiz 22
Answers 22
3. Adding Web Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
I Want My CSS! 23
Specifying Stylesheets 28
Creating a Layout for a Controller 29
Choosing a Layout from a Controller 31
Sharing Template Data with the Layout 33
Setting a Default Page 34
Test Your Knowledge 36
Quiz 36
Answers 36
iii
4. Managing Data Flow: Controllers and Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Getting Started, Greeting Guests 37
Application Flow 42
Keeping Track: A Simple Guestbook 44
Connecting to a Database Through a Model 44
Connecting the Controller to the Model 47
Finding Data with ActiveRecord 52
Test Your Knowledge 54
Quiz 54
Answers 54
5. Accelerating Development with Scaffolding and REST . . . . . . . . . . . . . . . . . . . . . . . . 57
A First Look at Scaffolding 57
REST and Controller Best Practices 61
Websites and Web Applications 61
Toward a Cleaner Approach 63
Examining a RESTful Controller 64
Index: An Overview of Data 69
Show: Just One Row of Data 71
New: A Blank Set of Data Fields 71
Edit: Hand Me That Data, Please 72
Create: Save Something New 72
Put This Updated Record In 74
Destroy It 75
Escaping the REST Prison 76
Test Your Knowledge 76
Quiz 76
Answers 77
6. Presenting Models with Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
More Than a Name on a Form 79
Generating HTML Forms with Scaffolding 80
Form as a Wrapper 84
Creating Text Fields and Text Areas 87
Labels 89
Creating Checkboxes 90
Creating Radio Buttons 91
Creating Selection Lists 93
Dates and Times 95
Creating Helper Methods 97
Test Your Knowledge 100
Quiz 100
Answers 100
iv | Table of Contents
7. Strengthening Models with Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Without Validation 103
The Original Model 106
The Power of Declarative Validation 106
Managing Secrets 109
Customizing the Message 109
Limiting Choices 111
Testing Format with Regular Expressions 112
Seen It All Before 112
Numbers Only 113
A Place on the Calendar 114
Testing for Presence 115
Beyond Simple Declarations 115
Test It Only If 115
Do It Yourself 116
Test Your Knowledge 117
Quiz 117
Answers 117
8. Improving Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Adding a Picture by Uploading a File 119
File Upload Forms 120
Model and Migration Changes 120
Results 126
Standardizing Your Look with Form Builders 129
Supporting Your Own Field Types 130
Adding Automation 132
Integrating Form Builders and Styles 134
Test Your Knowledge 137
Quiz 137
Answers 138
9. Developing Model Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Connecting Awards to Students 140
Establishing the Relationship 140
Supporting the Relationship 141
Guaranteeing a Relationship 145
Connecting Students to Awards 146
Removing Awards When Students Disappear 146
Counting Awards for Students 147
Nesting Awards in Students 148
Changing the Routing 149
Changing the Controller 150
Table of Contents | v
Changing the Award Views 153
Connecting the Student Views 156
Is Nesting Worth It? 158
Many-to-Many: Connecting Students to Courses 159
Creating Tables 159
Connecting the Models 161
Adding to the Controllers 162
Adding Routing 164
Supporting the Relationship Through Views 164
What’s Missing? 172
Test Your Knowledge 172
Quiz 172
Answers 173
10. Managing Databases with Migrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
What Migrations Offer You 175
Migration Basics 176
Migration Files 177
Running Migrations Forward and Backward 178
Inside Migrations 180
Working with Tables 181
Data Types 181
Working with Columns 183
Indexes 183
Other Opportunities 184
Test Your Knowledge 185
Quiz 185
Answers 185
11. Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Creating Your Own Debugging Messages 187
Raising Exceptions 188
Logging 188
Working with Rails from the Console 190
The Ruby Debugger 195
Test Your Knowledge 199
Quiz 199
Answers 199
12. Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Test Mode 201
Setting Up a Test Database with Fixtures 202
Unit Testing 206
vi | Table of Contents
Functional Testing 212
Calling Controllers 214
Testing Responses 215
Dealing with Nested Resources 216
Integration Testing 218
Beyond the Basics 220
Test Your Knowledge 221
Quiz 221
Answers 221
13. Sessions and Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Getting Into and Out of Cookies 223
Storing Data Between Sessions 230
Test Your Knowledge 235
Quiz 235
Answers 235
14. Users and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Installation 237
Storing Identities 239
Storing User Data 239
Wiring OmniAuth into the Application 240
Classifying Users 248
More Options 255
Test Your Knowledge 256
Quiz 256
Answers 256
15. Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Creating Routes to Interpret URIs 258
Specifying Routes with match 258
Globbing 260
Regular Expressions and Routing 261
A Domain Default with root 261
Named Routes 262
Mapping Resources 263
Nesting Resources 264
Route Order and Priority 265
Checking the Map 265
Generating URIs from Views and Controllers 266
Pointing url_for in the Right Direction 266
Adding Options 267
Infinite Possibilities 267
Table of Contents | vii
Test Your Knowledge 268
Quiz 268
Answers 268
16. From CSS to SASS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Getting Started 271
Sassy Style 272
Variables 272
Mixins 274
Nesting 275
Making Everything Work Together 276
Becoming Sassier 279
Test Your Knowledge 280
Quiz 280
Answers 280
17. Managing Assets and Bundles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
The Junk Drawer 281
Sprockets 282
Dissecting The Pipeline 283
Putting It All Together 283
Bundler 286
Test Your Knowledge 290
Quiz 290
Answers 290
18. Sending Code to the Browser: JavaScript and CoffeeScript . . . . . . . . . . . . . . . . . . . 291
Sending JavaScript to the Browser 292
Simplifying with CoffeeScript 293
Have Some Sugar with your CoffeeScript 295
Converting to CoffeeScript 297
Test Your Knowledge 298
Quiz 298
Answers 298
19. Mail in Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Sending Mail Messages 299
Receiving Mail 304
Setup 305
Processing Messages 305
Test Your Knowledge 308
Quiz 308
Answers 308
viii | Table of Contents
20. Pushing Further into Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Changing to Production Mode 309
Deploying Is Much More Than Programming 310
Joining the Rails Ecosystem 313
Keep Up with Rails 313
Ruby 313
Working With and Around Rails 314
Keep Exploring 314
A. An Incredibly Brief Introduction to Ruby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
B. An Incredibly Brief Introduction to Relational Databases . . . . . . . . . . . . . . . . . . . . 335
C. An Incredibly Brief Guide to Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
D. Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Table of Contents | ix
Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent
Preface
Everyone cool seems to agree: Ruby on Rails is an amazing way to build web
applications. Ruby is a powerful and flexible programming language, and Rails takes
advantage of that flexibility to build a web application framework that takes care of a
tremendous amount of work for the developer. Everything sounds great!
Except, well… all the Ruby on Rails books talk about this “Model-View-Controller”
thing, and they start deep inside the application, close to the database, most of the time.
From an experienced Rails developer’s perspective, this makes sense—the framework’s
power lies largely in making it easy for developers to create a data model quickly, layer
controller logic on top of that, and then, once all the hard work is done, put a thin layer
of interface view on the very top. It’s good programming style, and it makes for more
robust applications. Advanced Ajax functionality seems to come almost for free!
From the point of view of someone learning Ruby on Rails, however, that race to show
off Rails’ power can be extremely painful. There’s a lot of seemingly magical behavior
in Rails that works wonderfully—until one of the incantations isn’t quite right and
figuring out what happened means unraveling all that work Rails did. Rails certainly
makes it easier to work with databases and objects without spending forever thinking
about them, but there are a lot of things to figure out before that ease becomes obvious.
If you’d rather learn Ruby on Rails more slowly, starting from pieces that are more
familiar to the average web developer and then moving slowly into controllers and
models,you’reintherightplace.YoucanstartfromtheHTMLyoualreadylikelyknow,
and then move more deeply into Rails’ many interlinked components.
This updated version of Learning Rails covers version 3.2. There are
substantial changes from earlier versions. Rails itself keeps changing,
even in ways that affect beginners.
Who This Book Is For
You’ve probably been working with the Web for long enough to know that writing web
applications always seems more complicated than it should be. There are lots of parts
xi
to manage, along with lots of people to manage, and hopefully lots of visitors to please.
Ruby on Rails has intrigued you as one possible solution to that situation.
You may be a designer who’s moving toward application development or a developer
who combines some design skills with some programming skills. You may be a
programmer who’s familiar with HTML but who lacks the sense of grace needed to
create beautiful design—that’s a fair description of one of the authors of this book,
anyway. Wherever you’re from, whatever you do, you know the Web well and would
like to learn how Rails can make your life easier.
The only mandatory technical prerequisite for reading this book is direct familiarity
with HTML and a general sense of how programming works. You’ll be inserting Ruby
codeintothatHTMLasafirststeptowardwritingRubycodedirectly,sounderstanding
HTML is a key foundation. (If you don’t know Ruby at all, you probably want to look
over Appendix A or at least keep it handy for reference.)
Cascading Style Sheets (CSS) will help you make that HTML look a lot nicer, but it’s
not necessary for this book. Similarly, a sense of how JavaScript works may help.
Experience with other templating languages (like PHP, ASP, and ASP.NET) can also
help, but it isn’t required.
You also need to be willing to work from the command line sometimes. The commands
aren’t terribly complicated, but they aren’t (yet) completely hidden behind a graphical
interface.
Who This Book Is Not For
We don’t really want to cut anyone out of the possibility of reading this book, but there
are some groups of people who aren’t likely to enjoy it. Model-View-Controller purists
will probably grind their teeth through the first few chapters, and people who insist
that data structures are at the heart of a good application are going to have to wait an
even longer time to see their hopes realized. If you consider HTML just a nuisance that
programmers have to put up with, odds are good that this book isn’t for you. Most of
the other Ruby on Rails books, though, are written for people who want to start from
the model!
Also, people who are convinced that Ruby and Rails are the one true way may have
some problems with this book, which spends a fair amount of time warning readers
about potential problems and confusions they need to avoid. Yes, once you’ve worked
with Ruby and Rails for a while, their elegance is obvious. However, reaching that level
of comfort and familiarity is often a difficult road. This book attempts to ease as many
of those challenges as possible by describing them clearly.
xii | Preface
What You’ll Learn
Building a Ruby on Rails application requires mastering a complicated set of skills. You
may find that—depending on how you’re working with it, and who you’re working
with—you only need part of this tour. That’s fine. Just go as far as you think you’ll need.
At the beginning, you’ll need to install Ruby on Rails. We’ll explore different ways of
doing this, with an emphasis on easier approaches to getting Ruby and Rails
operational.
Next, we’ll create a very simple Ruby on Rails application, with only a basic view and
then a controller that does a very few things. From this foundation, we’ll explore ways
to create a more sophisticated layout using a variety of tools, learning more about Ruby
along the way.
Once we’ve learned how to present information, we’ll take a closer look at controllers
and what they can do. Forms processing is critical to most web applications, so we’ll
build a few forms and process their results, moving from the simple to the complex.
Forms can do interesting things without storing data, but after a while it’s a lot more
fun to have data that lasts for more than just a few moments. The next step is setting
up a database to store information and figuring out how the magic of Rails’
ActiveRecord makes it easy to create code that maps directly to database structures—
without having to think too hard about database structures or SQL.
Once we have ActiveRecord up and running, we’ll explore scaffolding and its possi-
bilities. Rails scaffolding not only helps you build applications quickly, it helps you
learn to build them well. The RESTful approach that Rails emphasizes will make it
simpler for you to create applications that are both attractive and maintainable. For
purposes of illustration, using scaffolding also makes it easier to demonstrate one task
at a time, which we hope will make it easier for you to understand what’s happening.
Ideally, at this point, you’ll feel comfortable with slightly more complicated data mod-
els, and we’ll take a look at applications that need to combine data in multiple tables.
Mixing and matching data is at the heart of most web applications.
We’ll also take a look at testing and debugging Rails code, a key factor in the frame-
work’s success. Migrations, which make it easy to modify your underlying data
structures (and even roll back those changes if necessary), are another key part of Rails’
approach to application maintainability.
The next step will be to add some common web applications elements like sessions and
cookies, as well as authentication. Rails (with the help of gems for authentication) can
manage a lot of this work for you.
We’ll also let Rails stretch its legs a bit, showing off its recent support for Syntactically
Awesome Stylesheets (Sass), CoffeeScript scripting, bundle management, and sending
email messages.
Preface | xiii
By the end of this tour, you should be comfortable with working in Ruby on Rails. You
may not be a Rails guru yet, but you’ll be ready to take advantage of all of the other
resources out there for becoming one.
Ruby and Rails Style
It’s definitely possible to write Ruby on Rails code in ways that look familiar to
programmers from other languages. However, that code often isn’t really idiomatic
Ruby, as Ruby programmers have chosen other paths. In general, this book will always
try to introduce new concepts using syntax that’s likely to be familiar to developers
from other environments, and then explain what the local idiom does. You’ll learn to
write idiomatic Ruby that way (if you want to), and at the same time you’ll figure out
how to read code from the Ruby pros.
We’ve tried to make sure that the code we present is understandable to those without
a strong background in Ruby. Ruby itself is worth an introductory book (or several),
but the Ruby code in a lot of Rails applications is simple, thanks to the hard work the
framework’s creators have already put into it. You may want to install Rails in Chap-
ter 1, and then explore Appendix: “An Incredibly Brief Introduction to Ruby” before
diving in.
Other Options
There are lots of different ways to learn Rails. Some people want to learn Ruby in detail
before jumping into a framework that uses it. That’s a perfectly good option, and if you
want to start that way, you should explore the following books:
• Learning Ruby by Michael Fitzgerald (O’Reilly, 2007)
• The Ruby Programming Language by David Flanagan and Yukhiro Matsumoto
(O’Reilly, 2008)
• Ruby Pocket Reference by Michael Fitzgerald (O’Reilly, 2007)
• Programming Ruby, Third Edition by Dave Thomas with Chad Fowler and Andy
Hunt (Pragmatic Programmers, 2008)
• The Well-Grounded Rubyist by David A. Black (Manning, 2009)
• Eloquent Ruby by Russ Olsen (Addison-Wesley, 2011)
• Metaprogramming Ruby by Paolo Perrotta (Pragmatic Programmers, 2010)
You may also want to supplement (or replace) this book with other books on Rails. If
you want some other resources, you can explore:
• For maximum excitement, try http://railsforzombies.com/, a training tool that
includes video and exercises.
xiv | Preface
• Try http://railscasts.com/ for all kinds of detailed programming demonstrations in
a video format.
• Ruby on Rails 3 Tutorial by Michael Hartl (Addison-Wesley, 2010), provides a
faster-moving introduction that covers many more extensions for Rails.
• The Rails 3 Way by Obie Fernandez (Addison-Wesley, 2010), takes a big-book
reference approach for developers who already know their way.
• Agile Web Development with Rails, Fourth Edition, (Pragmatic Programmers,
2010), by Sam Ruby, Dave Thomas, and David Heinemeier Hansson gives a de-
tailed explanation of a wide range of features.
Ideally, you’ll want to make sure that whatever books or online documentation you
use cover at least Rails 3.0 (or later). Rails’ perpetual evolution has unfortunately made
it dangerous to use a lot of formerly great but now dated material (some of it works,
some of it doesn’t).
Finally, key resources you should always explore are the Ruby on Rails Guides (http://
guides.rubyonrails.org/), which provide an excellent and well-updated overview for a
lot of common topics. Sometimes they leave gaps or demand more background
knowledge than beginners have, but they’re a wonderful layer of documentation at a
level above the basic (though also useful) API documentation at http://api.rubyonrails
.org/.
Rails Versions
The Rails team is perpetually improving Rails and releasing new versions. This book
was updated for Rails 3.2.3 and Ruby 1.9.2.
If You Have Problems Making Examples Work
When you’re starting to use a new framework, error messages can be hard, even
impossible, to decipher. We’ve included occasional notes in the book about particular
errorsyoumight see,but it seemsverynormal for different peopletoencounterdifferent
errors as they work through examples. Sometimes it’s the result of skipping a step or
entering code just a little differently than it was in the book. It’s probably not the result
of a problem in Rails itself, even if the error message seems to come from deep in the
framework. That isn’t likely an error in the framework, but much more likely a problem
the framework is having in figuring out how to deal with the unexpected code it just
encountered.
If you find yourself stuck, here are a few things you should check:
What version of Ruby are you running?
You can check by entering ruby -v. All of the examples in this book were written
with Ruby 1.9.2. You can also use Ruby 1.8.7 with Rails, but many of the examples
Preface | xv
here (especially those using hashes) may not always work for you. Versions of Ruby
older than 1.8.7 may cause problems for Rails 3.x, and even version 1.9.1 of Ruby
causes problems. Chapter 1 explores how to install Ruby, but you may need to
find documentation specific to your specific operating system and environment.
What version of Rails are you running?
You can check by running rails -v. You might think that you should be able to
use the examples here with any version of Rails 3.x, but Rails keeps changing in
ways that break even simple code even among the 3.x versions. The examples on
the book’s site include a number of versions from Rails 2.1 to Rails 3.2. If you’re
running a version of Rails other than 3.2, especially an earlier version, you will
encounter problems.
Are you calling the program the right way?
Linux and Mac OS X both use a forward slash, /, as a directory separator, whereas
Windows uses a backslash, . This book uses the forward slash, but if you’re in
Windows, you may need to use the backslash. Leaving out an argument can also
produce some really incomprehensible error messages.
Is the database connected?
By default, Rails expects you to have SQLite up and running, though some instal-
lations use MySQL or other databases. If you’re getting errors that have “sql” in
them somewhere, it’s probably the database. Check that the database is installed
and running, that the settings in database.yml are correct, and that the permissions,
if any, are set correctly.
Are all of the pieces there?
Most of the time, assembling a Rails application, even a simple one, requires
modifying multiple files—at least a view and a controller. If you’ve only built a
controller, you’re missing a key piece you need to see your results; if you’ve only
built a view, you need a controller to call it. As you build more and more complex
applications, you’ll need to make sure you’ve considered routing, models, and
maybe even configuration and plug-ins. What looks like a simple call in one part
of the application may depend on pieces elsewhere.
Eventually, you’ll know what kinds of problems specific missing pieces cause, but
at least at first, try to make sure you’ve entered complete examples before running
them.
It’s also possible to have files present but with the wrong permissions set. If you
know a file is there, but Rails can’t seem to get to it, check to make sure that
permissions are set correctly.
Did you save all the files?
Of course this never happens to you. However, making things happen in Rails often
means tinkering with multiple files at the same time, and it’s easy to forget to save
one as you move along. This can be especially confusing if it was a configuration
or migration file. Always take a moment to make sure everything you’re editing
has been saved before trying to run your application.
xvi | Preface
Are your routes right?
If you can’t get a page to come up, you probably have a problem with your routes.
This is a more common problem when you’re creating controllers directly, as you
will be up through Chapter 4, rather than having Rails generate scaffolding. Check
config/routes.rb.
Is everything named correctly?
Rails depends on naming conventions to establish connections between data and
code without you having to specify them explicitly. This works wonderfully, until
you have a typo somewhere obscure. Rails also relies on a number of Ruby con-
ventions for variables, prefacing instance variables with @ or symbols with :. These
special characters make a big difference, so make sure they’re correct.
Is the Ruby syntax right?
If you get syntax errors, or sometimes even if you get a nil object error, you may
have an extra space, missing bracket, or similar issue. Ruby syntax is extremely
flexible, so you can usually ignore the discipline of brackets, parentheses, or
spaces—but sometimes it really does matter.
Is another Rails app running?
Jumping quickly between programs can be really confusing. In a normal develop-
ment cycle, you’ll just have one app running, and things just work. When you’re
reading a book, especially if you’re downloading the examples, it’s easy to start an
app, close the window you use to explore it, and forget it’s still running underneath.
Definitely stop one server before running another while you’re exploring the apps
in this book.
Are you running the right program?
Yes, this sounds weird. When you’re developing real programs, it makes sense to
leave the server running to check back and forth with your changes. If you’re testing
out a lot of small application examples quickly, though, you may have problems.
Definitely leave the server running while you’re working within a given example,
but stop it when you change chapters or set off to create a new application with
the rails command.
Does your model specify attr_accessible?
Rails tightened its security rules in Rails 3.2, requiring that models include an
attr_accessible declaration at the start, identifying which fields can be reached
through Rails. Older code, even code from earlier versions of this book, generally
didn’t do this. If you get error messages like “Can’t mass-assign protected
attributes,” this is likely the problem.
Did the authors just plain screw up?
Obviously, we’re working hard to ensure that all of the code in this book runs
smoothly the first time, but it’s possible that an error crept through. You’ll want
to check the errata, described in the next section, and download sample code,
which will be updated for errata.
Preface | xvii
It’s tempting to try Googling errors to find a quick fix. Unfortunately, the issues just
described are more likely to be the problem than something else that has clear
documentation. The Rails API documentation (http://api.rubyonrails.org/) might be
helpful at times, especially if you’re experimenting with extending an example. There
shouldn’t be much out there, though, beyond the book example files themselves that
you can download to fix an example.
If You Like (or Don’t Like) This Book
If you like—or don’t like—this book, by all means, please let people know. Amazon
reviews are one popular way to share your happiness (or lack of happiness), or you can
leave reviews on the site for this book:
http://www.oreilly.com/catalog/9781449309336/
There’s also a link to errata there. Errata gives readers a way to let us know about typos,
errors, and other problems with the book. The errata will be visible on the page
immediately, and we’ll confirm it after checking it out. O’Reilly can also fix errata in
future printings of the book and on Safari, making for a better reader experience pretty
quickly.
We hope to keep this book updated for future versions of Rails and will also incorporate
suggestions and complaints into future editions.
Conventions Used in This Book
The following font conventions are used in this book:
Italic
Indicates pathnames, filenames, and program names; Internet addresses, such as
domain names and URLs; and new items where they are defined.
Constant width
Indicates command lines and options that should be typed verbatim; names and
keywords in programs, including method names, variable names, and class names;
and HTML element tags.
Constant width bold
Indicates emphasis in program code lines.
Constant width italic
Indicates text that should be replaced with user-supplied values.
This icon signifies a tip, suggestion, or general note.
xviii | Preface
This icon indicates a warning or caution.
Using Code Examples
The code examples for this book, which are available from http://oreil.ly/Learning
Rails3, come in two forms. One is a set of examples, organized by chapter, with each
example numbered and named. These examples are referenced from the relevant chap-
ter. The other form is a dump of all the code from the book, in the order it was presented
in the book. That can be helpful if you need a line that didn’t make it into the final
example, or if you want to cut and paste pieces as you walk through the examples.
Hopefully, the code will help you learn.
So far, the code examples for this electronic version of the book have stayed in sync
with the code examples for the print book, updated for errata.
This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: “Learning Rails 3 by Simon St.Laurent,
Edd Dumbill, and Eric J. Gruber. Copyright 2012 Simon St.Laurent, Edd Dumbill, and
Eric Gruber, 978-1-449-30933-6.”
If you feel your use of code examples falls outside fair use or the permission given above,
feel free to contact us at permissions@oreilly.com.
Safari® Books Online
Safari Books Online (www.safaribooksonline.com) is an on-demand digital
library that delivers expert content in both book and video form from the
world’s leading authors in technology and business.
Technology professionals, software developers, web designers, and business and cre-
ative professionals use Safari Books Online as their primary resource for research,
problem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organi-
zations, government agencies, and individuals. Subscribers have access to thousands
Preface | xix
of books, training videos, and prepublication manuscripts in one fully searchable
database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-
Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco
Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe
Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course
Technology, and dozens more. For more information about Safari Books Online, please
visit us online.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at:
http://oreil.ly/LearningRails3
To comment or ask technical questions about this book, send email to:
bookquestions@oreilly.com
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
Thanks to Mike Loukides for thinking that Rails could use a new and different ap-
proach, and for supporting this project along the way. Tech reviewers Gregg Pollack,
Shelley Powers, Mike Fitzgerald, Eric Berry, David Schruth, Mike Hendrickson, and
Mark Levitt all helped improve the first edition of the book tremendously. For this
edition, Aaron Sumner, David DeMello, and Alan Harris went through the details
carefully, finding many changes we’d overlooked and making helpful suggestions. The
rubyonrails-talk group providedregularinspiration,asdidthe screencastsandpodcasts
at http://railscasts.com/.
xx | Preface
Edd Dumbill wishes to thank his lovely children, Thomas, Katherine, and Peter, for
bashing earnestly on the keyboard, and his coauthor, Simon St.Laurent, for his patient
encouragement in writing this book.
Simon St.Laurent wants to thank Angelika St.Laurent for her support over the course
of writing this, even when it interfered with dinner, and Sungiva and Konrad St.Laurent
for their loudly shouted suggestions. Simon would also like to thank Edd Dumbill for
his initial encouragement and for making this book possible.
Eric would like to thank his lovely wife for enduring many late-night endeavors to learn
about this wonderful world of code, his parents and sister for always encouraging him
to find his own path, his community of designers and developers in the Lawrence area,
Aaron Sumner for being a patient guide in the Ruby world, and his children, who inspire
him to learn how to code well enough to teach it to them (if that’s what they want).
We’d all like to thank Jasmine Perez for cleaning up our prose, Iris Febres for getting
this book through production, and Lucie Haskins for the patient work it takes to build
an index.
Preface | xxi
Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent
CHAPTER 1
Starting Up Ruby on Rails
Before you can use Rails, you have to install it. Even if it’s already installed on your
computer, you may need to consider upgrading it. In this chapter, we’ll take a look at
some ways of installing Ruby, Rails, and the supporting infrastructure. Please feel very
welcome to jump to whatever pieces of this section interest you and skip past those
that don’t. Once the software is working, we’ll generate the basic Rails application,
which will at least let you know if Rails is working. However you decide to set up Rails,
in the end you’re going to have a structure like that shown in Figure 1-1.
Figure 1-1. The many components of a Rails installation
1
Discovering Diverse Content Through
Random Scribd Documents
contemplated Mr. Higgins, and in a mocking tone that he repeated
for the second time,
"Such a very honest tradesman as Mr. Higgins! Get on, will you?
You left off where you'd been having all the papers read to you."
That the doubt as to the success of his enterprise which Dick's
independent manner had introduced was not lessened was apparent,
for though what he said was pregnant enough his tone lost
something of its confidence.
"Yes, I gets 'em all read out to me, and it sets me thinking. 'What
call has Mr. Dick Remington got to keep it dark?' says I to myself.
'Why don't he say nothing about it? There's something in the wind.
He comes to my shop, and buys a rope and grapnel in a secret sort
o' way'--"
"Wrong, my honest tradesman," interrupted Dick, and Mr. Higgins
shifted uneasily in his chair, "I bought it openly. Did I ask you to
keep it dark?"
"No, you didn't, but did you go out of my shop with the rope
hanging over your arm?' O-ho!' says I, 'here's a working man
ashamed to carry a rope. He asks for a bit of paper to wrap it up in,
he does, and he puts it under his coat, he does. That's a rum sort o'
working man,' says I."
"Clever Mr. Higgins," said Dick, patronisingly, "clever Mr. Higgins!"
"Do you mean to tell me," said that worthy, driven to exasperation
by Dick's coolness, "that you didn't use it to get over the wall at the
back of Samuel Boyd's house in Catchpole Square, that it wasn't you
as broke the kitchen winder, that you didn't break open the safe--"
"Hold hard," said Dick, "you've had the papers read wrong. The
safe was not broken open."
"What does that matter?" snarled Mr. Higgins. "Broke open, or
opened with a key, it's all the same. The man as did it helped hisself
to the money and jewels, and made off with the swag--with my rope
and grapnel that cost me its weight in gold--how does that strike
you, Mr. Dick?"
"You old fool," said Dick, with a broad smile, "if you knock your
head against that brick wall you'll knock out the few brains you
possess. If you think I can't reckon up an honest tradesman like you,
you were never more mistaken in your life." And with the forefinger
of his right hand he tapped the side of his nose, and winked at Mr.
Higgins.
But though he spoke and acted thus boldly he fully recognised the
seriousness of this new danger. Say that this man laid information
against him at the first police station; say that it got to the
knowledge of Detective Lambert who was searching everywhere for
a clue to the mystery. What would be the consequence? A warrant
would be immediately issued for his arrest, and a search warrant as
well. The rope and grapnel, tied up in brown paper, was now under
the bed of his room in Constable Pond's house, and the key of that
room was in his pocket. How could he explain away his possession
of the rope? He would be asked why he made no mention of it at
the inquest; his silence regarding it would be a piece of damning
evidence against him. And not the only piece. His prowling about in
the neighbourhood of Catchpole Square at an early hour of the
morning, as testified by Constable Applebee, was in the highest
degree suspicious when taken in connection with his possession of
the rope and grapnel. His knowledge of the habits of Samuel Boyd,
gained during his employment as clerk in the house, would be
against him. One thing was certain. He would be deprived of his
liberty, and the contemplation of this contingency filled him with
dismay. Everything depended upon his being free to carry out the
plans he had formed, and therefore upon his turning the tables upon
the old vagabond who sat leering into his face.
And in the event of his being arrested, what would be said of him
in Aunt Rob's home? Was it not probable, aye, more than probable,
that they would suspect him to be the murderer? He had woven a
net for himself, and if he were not careful he would drag down
Reginald with him. Press and public would say "collusion," and the
chain of circumstantial evidence be too strong for him to break
through.
Admitting all this, he felt that any sign of weakness in the
presence of Mr. Higgins would be fatal. There was nothing for it but
to play the bold game.
"I've a good mind," he said, slowly and sternly, "to go and give
information against you."
"What do you mean?" demanded Mr. Higgins, his features
twitching more hideously than ever. Dick hailed these signs of
discomposure with delight, and encouraged by the impression his
sarcastic references to Mr. Higgins as an honest tradesman had
produced he was quick to take advantage of it. He resembled the
gambler who stakes his whole fortune upon the last throw.
"Did you ever see the secret books of the police," he said, "with
the names of certain men with black marks against them? Why, we
can lay our hands upon every thief and fence in London when we
want to--do you hear? when we want to." Mr. Higgins winced.
"There are some things that lick us for a time, like this Catchpole
Square Mystery, but we don't go to sleep over them, though some
people may think we do. And when we're playing a high game we
don't show our cards. What I mean is, that we'll have your place
searched for stolen goods. How will that suit you, my honest
tradesman? We can bring one or two things against you that you'll
find it hard to explain when you're in the dock. If we let you alone
it's because you're not worth the powder and shot, but get our
dander up, Mr. Higgins, and we'll make short work of you. How does
that suit your book? Take care of your precious self, my man, and let
sleeping dogs lie."
It was vague, but effective, and it was Dick's good fortune that
the hazardous shot told. Indeed, it had gone straight to the bull's
eye. Many were the questionable transactions in which, from time to
time, Mr. Higgins had been engaged. Petty thieves in the
neighbourhood were in the habit of selling their small spoils across
his counter; this modern Fagin was always ready to buy, and no
questions asked. He had been in trouble more than once, and was in
mortal dread of getting into trouble again. This, of course, was
unknown to Dick, and it was only from his familiarity with the nature
of much of the business transacted in some of these second-hand
shops in mean streets that he had ventured upon the bold attack.
He could have hugged himself when he saw the effect it produced
upon Mr. Higgins.
"There is nothing like a good understanding in these matters, Mr.
Higgins," he continued, "and I've no wish to be hard on you. I've got
my own game to play, and it's keeping me pretty busy. Between
ourselves--don't be frightened, there's nobody by--I did purchase a
rope and grapnel of you, but is it for you to say whether I purchased
it for myself or for another person, and what use I made of it? I
might deny it if I chose, and then, my honest tradesman, who would
take your word against mine? Is there any magistrate's court in
London where your oath would be believed, much less your word?
What a blind fool you are! Upon my word I gave you credit for more
sense. Perhaps the reporter of 'The Little Busy Bee' used a rope and
grapnel, perhaps he didn't. Perhaps it was the one I bought of you,
perhaps it wasn't. I'm not going to let you into the know, Mr.
Higgins. How would you like to have the papers down on you as well
as the police? How do you know I'm not acting under instructions to
track and catch the murderer or murderers of Samuel Boyd? How do
you know"--here he leaned forward, and tapped Mr. Higgins
confidentially on the breast--"that I'm not in the secret service
myself? Would you like to hear what is in these bills that you are
going to help me stick on the walls? I've just come from the printing
office where I've had them printed. You can't read, you say; it is a
pity you should be left in the dark, so I'll read it to you." Dick spread
one out, and read it aloud, with unction. "It reads well, doesn't it?
I'm rather proud of it. That's a figure of Justice on the top. My idea.
Rather a good idea, I flatter myself. A pretty fellow you are to come
and threaten me with your rope and grapnel! I'll tell you what your
game is, Mr. Higgins. Blackmail. That is it--blackmail. A dangerous
game, old man, and you've got hold of the wrong end of the stick--
perhaps you see that now. If I had anything to fear is it likely that
I'd be going about in open daylight sticking up these bills? More
likely to be sailing on the open seas for some foreign port. Where
are your wits, you clumsy idiot?"
To judge from Mr. Higgins's appearance, they had gone wool-
gathering. He literally gasped beneath the volley which Dick had
poured upon him, at the end of which he was sitting in his chair in a
state of helpless collapse. Dick had turned the tables upon him with
a vengeance.
"Now, what have you got to say?" he asked, triumphantly.
"Quartern o' rum," gasped Mr. Higgins.
"When we've finished our confab you shall have it, and another
one or two on the top of it as we go along. Lord bless you, Mr.
Higgins, I'm not an ill-natured chap, if you take me easy, and I have
the credit of generally being freehanded when I'm not interfered
with. Pull yourself together, and listen to what more I've got to say.
What we want to do--the secret service, the detectives, the Criminal
Investigation Department, and all of us--is to keep this matter as
quiet as possible till the thieves and murderers are nabbed. We're
working on the strict q.t., and we've got something up our sleeve, I
can tell you. And I'll tell you something more. If any outsider
interferes with our game by blabbing about ropes and grapnels it will
be the worst day's work he
has ever done, and he'll live to rue it. We'll wipe him out, that's what
we'll do. We'll have no mercy on him."
This was the finishing stroke. Mr. Higgins lay helpless at the foot
of the conqueror.
"I made a mistake," he whined. "Quartern o' rum."
"You would sell your own mother for drink, I believe."
"No, no," protested Mr. Higgins, feebly, "not so bad as that, not so
bad as that. Good for my liver. Keeps me alive."
"A nice state your liver must be in," said Dick, laughing. "I think
we understand each other. Take up the paste pot, and carry it
steady. You shall be paid for your day's work. Tenpence an hour, so
look sharp."
Mr. Higgins, completely subdued, had his fourth quartern at the
bar, and shortly afterwards the British public had the privilege of
seeing Dick Remington stick up the murder bills, assisted by an old
man in skull cap and list slippers, in that stage of palsy from his
recent experiences that his course was marked by a dribble of paste
spilt from the pot he carried in his trembling hands. At every fresh
stoppage a crowd gathered, arguing, disputing, airing theories.
These chiefly consisted of conjectures as to who the murderer was,
how the murder had been committed, how many were in it, who the
man was who had been seen by Dr. Pye coming out of the house in
Catchpole Square at three in the morning, whether he was the same
man who had imposed upon Lady Wharton, how the blood-stained
marks of footsteps on the floor were to be accounted for, whether
there was any chance of the jewels being recovered, and so on, and
so on. At one place there was a conversation of a different nature.
"What I find fault with in that there bill," said an onlooker, a man
with a forbidding face, dressed in corduroy, "is that no pardon is
offered to any accomplice as didn't actually commit that there
murder. Where's the indoocement to peach on a pal, that's what I
want to know?"
"A white-livered skunk I'd call him whatever his name might be,"
remarked a second speaker. "Honour among thieves, that's what I
say."
"Oh, come," said a third, "let's draw the line somewhere."
"It's what they put in the bills," grumbled the man in corduroy,
offering no comment on these expressions of opinion, "and I don't
see no mention of it in that there blooming bill."
"It's what they put in the Government bills," said the second man,
"but this ain't a Government bill. It's a reward of £500 offered by a
private individual."
"A private individual!" sneered the first speaker. "You don't call Mr.
Reginald Boyd a private individual in this here case, do you? He's a
interested party, that's what he is. What I say is--and anybody can
take it up as likes--where's the indoocement to peach on a pal?"
"Well, don't take it to heart, mate," said another. At which there
was a general laugh. "Do you know how it runs in the Government
bills?"
"No, I don't; but I know it's alias there, and allus should be
there."
"I can give you the words, if you wish to hear them," said a quiet
onlooker, who, meditatively rubbing his chin, was watching the
crowd and the billsticker.
Dick repressed a start. It was the voice of Detective Lambert, with
whom he was acquainted. He turned and accosted the officer, who
put his finger to his lips, thus indicating that they were not to
address each other by name.
"Good morning," said Dick.
"Good morning," said Lambert. "I did not know you were in this
line of business."
"Anything to turn an honest penny, said Dick, cheerfully.
"Give us the words, mate," said the man in corduroy.
"They run in this way. 'And the Secretary of State for the Home
Department will advise the grant of her Majesty's gracious Pardon to
any accomplice not being the person who actually committed the
murder, who shall give such evidence as shall lead to a like result.'"
"You seem to be well up in it, guv'nor."
"Fairly well. I did a turn in a Government printing office once."
"Then you could inform us, perhaps, as a matter of general
interest," said an elderly man, "whether the accomplice, who would
be Queen's evidence----"
"Yes, Queen's evidence."
"Would get the reward as well as the pardon?"
"In course he would," said the man in corduroy, answering for
Lambert. "That's the beauty of it. Only wish I was an accomplice in
this here blooming murder, with them words in that there bill orfered
by the Government. I'd touch, mates, pretty quick, that's what I'd
do. But as it stands, where's the indoocement? It ain't 'arf a bill
without the indoocement."
This insistence of the implied merit attaching to an act of
treachery did not seem to meet with the approval of many in the
crowd, who edged away, with distrustful looks at the speaker. Dick
also walked off, and Detective Lambert walked by his side awhile, Mr.
Higgins shambling humbly in the rear.
"A bold move," remarked Lambert.
"A proper move," said Dick. "Anything new stirring?"
Lambert rubbed his chin for two or three moments without
replying, and few persons would have supposed that he was paying
much visual attention to the man at his side or the man in the rear;
but Dick knew better. He knew that detective Lambert was one of
the shrewdest and the most observant officers in the service, and
that nothing escaped his attention.
"Five hundred pounds is a good round sum," he said.
"It is," said Dick. "Why not earn it?" Lambert gave him a curious
look, surprised, for one brief moment, out of himself. "If it was a
Government reward," continued Dick, who also had his eyes about
him, "there wouldn't be a chance for you, for the words would run,
'the above reward will be paid to any person (other than a person
belonging to a police force in the United Kingdom) who shall give
such information,' etc. Now, this reward doesn't apply in this way.
The reward will be willingly and gladly paid to any person, whether
he belongs to the police or not. Is it worth considering?"
"Yes," said Lambert, thoughtfully, "it is worth considering. You
asked me whether there's any thing new stirring. Well----" But he
paused suddenly, as if he were about to say too much. "One of
these days, perhaps, there will be a case in the papers that, for
daring and mystery, will beat even the Mystery of Catchpole
Square."
"Can't imagine one," said Dick. "It wouldn't be fair to ask if there's
any connection between the two cases." He paused; Lambert was
silent; Dick turned the subject. "What do you think of my new
apprentice? A modern species of Ganymede, carrying the pastepot
instead of the wine cup. Nothing like novelty in these days; people
run crazy after it. Only you must keep it well advertised; everything
depends upon that. Drop your advertisements, and youth grows
wrinkled in an hour. Now, what we're aiming at in this mystery"--he
flourished his paste brush--"is that, until we get at its heart, people
shan't forget it. We'll keep it before them morning, noon, and night.
No hole-in-the-corner business. Step up, old man." This to Mr.
Higgins, who came shambling forward, his features twitching twenty
to the dozen. With the eyes of so sharp an officer as Lambert upon
him Dick was not stupid enough to dream of keeping the old man in
the background. He knew that any such attempt would end in
Lambert's finding means of making himself thoroughly acquainted
with Mr. Higgins's business and character before the day was out, so
he took the bull by the horns, and introduced his companion by
name, giving also his trade and address. "There's a specimen of an
honest tradesman for you. Queer sort of assistant for me to pick
up?"
"There's no denying it," said Lambert.
"There's a little story attached to the way Mr. Higgins and I struck
up a friendship. What's the best thing in life worth living for, old
man?"
"Quartern o' rum," replied Mr. Higgins. The answer seemed to be
jerked out of him by force of magnetism.
Dick laughed; Lambert made a movement of departure.
"Are you off?" asked Dick.
"Off I am. Take care of yourself."
"I'll try to."
Dr. Pye's countenance during his late interview with Dr. Vinsen
was not more inscrutable than that of Detective Lambert. The
trained habit of concealing one's thoughts is part of the stock in
trade of more than one class of men, and shrewd as Dick was he
would have found it beyond his power to divine what was passing in
Lambert's mind as he strolled leisurely away, but a quiet smile on the
younger man's lips denoted that he was not dissatisfied with the
problem he had presented to the detective. "I've given him
something to puzzle over," was Dick's thought, "and I'm a Dutchman
if I haven't thrown him off the scent in regard to my friend Higgins."
"There's a man for you," he said, as he gazed admiringly after the
vanishing figure of the detective. "Have you the pleasure of knowing
the gentleman?"
"Can't say as I have," was the answer.
"That's the famous Detective Lambert, who gave evidence at the
inquest. And what a ferret he is! Search France and England
through, and you won't meet his match. He had his eye on you, I
noticed." Mr. Higgins shivered. "If ever you get into his clutches look
out for snakes. It's a pleasure to work with a man like that. He and I
are on the same lay."
Another hour's steady work, and the last bill was pasted on the
walls and the last quartern of rum disposed of. Then he reckoned up
what was due to Mr. Higgins, paid and dismissed him, and repeated
his caution about looking out for snakes if it should be his bad
fortune to fall into the clutches of the famous detective.
"I've about settled your hash," mused Dick, as he saw Mr. Higgins
plunge into the nearest beershop. "But how do I stand with
Lambert? That's a different pair of shoes. What did he mean about
another case of mystery? I thought he was going to let it out, but he
pulled himself up short. Never mind, Dick. You've had a narrow
squeak to-day, and you've got out of it with flying colours. Go ahead,
my lad, and stick at nothing."
Had Detective Lambert followed Dick to the neighbourhood of
Covent Garden and overheard what passed between him and certain
well known tradesmen therein he would have had another problem
to solve, in addition to those which were already occupying his
attention.
CHAPTER XLVI.
"THE LITTLE BUSY BEE'S" REPORT OF THE CONTINUATION
OF THE INQUEST.
The inquiry into the death of Mr. Samuel Boyd was resumed at
the Coroner's Court in Bishop Street this morning before Mr. John
Kent. Long before eleven o'clock the usual crowd of persons had
gathered round the doors, but so numerous had been the
application for seats from privileged and influential quarters that
very few of the general public succeeded in gaining admittance.
Intense as has been the interest evinced in this extraordinary case,
the startling and unexpected revelations made by witnesses who
have voluntarily come forward to give evidence have raised it to a
level reached by no other murder mystery in our remembrance. It
would be idle to deny that the evidence of the last witness examined
yesterday has given a significant turn to the proceedings.
So far as we have been able to ascertain, the police have
obtained no clue to the man who personated Samuel Boyd and who
so successfully imposed upon Lady Wharton in Bournemouth. We
understand that it is the intention of her ladyship's advisers to offer
a substantial reward for the recovery of her jewels, and a list of
them, with detailed descriptions, has been sent to every pawnbroker
in the kingdom. To this course we ourselves see no objection,
although we are aware that many of the Scotland Yard officials are
strongly of the opinion that the offer of a reward in such cases only
serves to put the guilty parties more carefully on their guard. For the
same reason they may object to the bills that are now being posted
in London offering rewards for the discovery and conviction of the
murderer or murderers, and for the discovery of Abel Death, of
whom no news whatever is as yet forthcoming. The bills are
appropriately headed "In the Cause of Justice," and it is to be hoped
that they will assist the cause of justice. We make no comment upon
the circumstance that Mr. Reginald Boyd, at whose instance this step
has been taken, has made himself responsible for the payment of
£500 in the one case and £200 in the other. The argument that it will
stimulate persons to recall apparently insignificant details in
connection with the movements of the guilty parties, and to make
them public, is sound, for important results have been known to
spring from the revelation of details which in ordinary circumstances
would be considered too trivial to mention. In the course of the next
few days further developments may be expected.
It was understood that this morning's proceedings would be
opened with the examination of Mrs. Abel Death, but before she was
called Mr. Reginald Boyd rose and addressed the Coroner.
Mr. Reginald Boyd: "I ask permission to say a few words."
The Coroner: "You have already been examined, Mr. Boyd, and I
am desirous not to subject the jury to the inconvenience arising from
an inquiry unduly protracted."
Mr. Reginald Boyd: "I can assure you, Mr. Coroner, and you,
gentlemen of the jury, that I do not wish to waste your time, but you
must see that what has transpired in the course of this inquiry
affects me most deeply. In common justice I ask to be heard."
The Juror: "Let us hear what Mr. Reginald Boyd has to say."
The Coroner: "I am in your hands, gentlemen."
Mr. Reginald Boyd: "After the evidence given by Dr. Pye--or rather
I should say, after the statement he has made affecting myself--my
desire is to declare even more positively than I did yesterday that I
reached my lodgings on Friday night within a few minutes of
midnight, that I went to bed, and did not arise from it for a week in
consequence of my illness. I fear that it is not in my power to offer
corroborative evidence. My landlady and her servant went to bed, I
understand, between ten and eleven o'clock, and have no
recollection of hearing anybody come into the house after they
retired. It is my misfortune, also, that I was the only lodger in the
house. I let myself in with my latchkey. I have no remembrance of
meeting with anyone nor of speaking to anyone, but I can swear to
the time because I looked at my watch, and wound it up in my
bedroom."
The Coroner: "Very well. Perhaps you had better not say anything
more."
Mr. Reginald Boyd: "Why not, Mr. Coroner? I desire it to be widely
known that I court the fullest and most searching inquiry. I cannot
avoid seeing that Dr. Pye's statement that the man he saw bore a
striking resemblance to myself throws a grave suspicion upon me. I
do not impugn his evidence, but I contend that it is only fair that
equal consideration should be given to my statement as to his. I will
endeavour to make myself clearer. I affirm upon my oath that I was
in my bed within a few minutes of midnight, and did not leave it
again. Dr. Pye affirms that three hours afterwards he saw a person
resembling me leave my father's house in a suspicious manner. To
the truth of my statement I can bring forward no witnesses. Can Dr.
Pye bring forward any witnesses to the truth of his? If
uncorroborated evidence given by me is open to doubt, so should
uncorroborated evidence given by him be viewed. A man's honour--
to say nothing of a son's innocence or guilt of so awful a crime as
the murder of his father--is not to be judged by a stranger's
unsupported word. In the sacred name of justice I protest against
it."
These words, spoken with manliness and deep emotion, made a
marked impression upon the audience, which was deepened when
they turned to the glowing face of the witness's wife. A murmur of
sympathy ran through the Court.
The Juror (referring to his notes): "But in your account of the
incidents of that night you informed us that you could not depend
upon your memory. Quoting your own words: 'I was deeply agitated,
and my mind was in confusion. The fever from which I immediately
afterwards suffered, and which kept me to my bed several days,
may have been upon me then.' Do you adhere to that?"
Mr. Reginald Boyd: "I do. In describing my condition my
endeavour was to speak the honest truth, and to offer no excuse
which could not be accepted by an impartial mind, nor to take
advantage of any. But that does not affect my distinct recollection as
to the time I wound up my watch in my bedroom."
The Juror: "We must not, however, lose sight of the fact that no
suspicion attaches to Dr. Pye, and that it is not his veracity that is
here in question."
Mr. Reginald Boyd (with warmth): "Is that a fair remark from one
of the jury?"
The Coroner: "It is a most improper remark, and should not have
been made in open Court. Call Mrs. Abel Death."
CHAPTER XLVII.
"THE LITTLE BUSY BEE" CONTINUES ITS REPORT OF THE
INQUEST.
The public are by this time acquainted with much of the evidence
Mrs. Death had to offer. After narrating the circumstances of her
husband's dismissal from the service of Mr. Samuel Boyd, and of his
going late at night to Mr. Boyd's house in Catchpole Square to beg to
be taken back, the examination proceeded as follows:
"What salary did your husband receive from Mr. Boyd?"
"Twenty-two shillings a-week, with deductions for imaginary
faults."
"Did he work long hours?"
"From nine in the morning till eight at night. Occasionally he
worked overtime, but was never paid anything extra."
"He was not happy in his situation?"
"How could he be, sir, with such a master?"
"They had frequent disagreements?"
"I'm sorry to say they had; but it wasn't my husband's fault."
"Did he ask Mr. Boyd for a loan of ten pounds?"
"Yes, sir."
"He hoped it would be granted?"
"We fully expected it, sir."
"The refusal to grant the loan must have been a great
disappointment to your husband?"
"It almost broke his heart, sir."
"May that not have exasperated him, and caused him to speak
words to Mr. Boyd which might have been construed into a threat?"
"I am sure that could not have happened. My husband was most
particular in telling me everything that passed between them, and
he didn't use a threatening word. He did ask Mr. Boyd if he believed
in God, and Mr. Boyd said no, he didn't."
"Then there was bad blood between them when they parted?"
"I suppose there was, sir."
"To what do you attribute Mr. Boyd's unexpected refusal to lend
the money?"
"To Mr. Reginald's visit in the afternoon. It made his father
furious."
"Now, as to the object of Mr. Reginald Boyd's visit in the
afternoon. Was it to obtain money from his father?"
"That was what my husband believed."
"And was this the object of his second visit late at night?"
"My husband said of course it must be that, but that he wouldn't
get a penny out of the old man."
"After your husband's dismissal, are you aware whether he and
Mr. Reginald Boyd met?"
"They couldn't have met, sir, or my husband would have told me."
"No doubt you have heard many of the theories that have been
advanced to account for his absence from his home?"
"Well, sir, I have. Some say--the wretches!--that he murdered Mr.
Boyd, and has run off with the money. Some say that he has made
away with himself, but it isn't possible he could have thought of such
a thing. I was a bit afraid of it the last night I saw him when he
started up to go to Catchpole Square, but he saw what was in my
mind, and he said, 'Don't you think that of me. You've got trouble
enough to bear; I'm not going to bring more upon you. I'll do my
duty, and fight on to the bitter end.' And that's what he would have
done."
"Have you any idea at all as to the cause of his absence?"
"Yes, sir. Foul play."
"Did he have any enemies?"
"Not to my knowledge, sir. He wasn't of a quarrelsome
disposition."
"Were there any money transactions between him and Mr.
Reginald Boyd?"
"Not exactly transactions, sir. Once, when we had sickness at
home, Mr. Reginald saw that my husband was worried, and he asked
him if he was in any trouble. Hearing what it was, and that we were
frightened to send for a doctor because of the expense, he gave my
husband two sovereigns. We thought it was a loan, but afterwards,
when we offered to pay it off at a shilling a week, Mr. Reginald said
it was only a friendly little present, and that he would be vexed if we
didn't look upon it as such. I remember my husband saying, 'I wish I
was working for Mr. Reginald instead of for his father.' We were very
grateful to him, and I always looked upon him as a model young
gentleman till old Mr. Boyd was murdered, and then----"
"Why do you pause? Go on."
"No, sir, I won't. It wouldn't be fair."
The Juror: "But we should like to hear, Mrs. Death?"
"I'm not going to say anything more about it, sir, unless you force
me to it. Every man ought to have his chance."
The Juror (to the Coroner): "I think, Mr. Coroner, the witness
should be directed to finish the sentence."
The Coroner (to Mrs. Death): "You would rather not say what is in
your mind?"
Mrs. Death: "I would rather not, sir."
"Then I shall not ask you to disclose it."
The Juror: "But, Mr. Coroner----"
The Coroner: "I am conducting this inquiry, and I have given my
decision." (To the witness). "How long did you remain up on Friday
night after your husband went to make a last appeal to his
employer?"
"I did not go to bed at all that night. I waited for him till nearly
two in the morning, and then I went to Catchpole Square, on the
chance that Mr. Samuel Boyd would be able to give me some
information of him. I knocked at the door, and hung about the
Square a goodish bit, but I couldn't get anyone to answer me. Then
I came home again, and waited and waited."
"You went from your house at two in the morning?"
"About that time, sir."
"How long did it take you to reach Catchpole Square?"
"It was a dark night, and I should think it took me half an hour or
so."
"So that you would be in front of Mr. Boyd's house at about half
past two?"
"Yes, sir."
"You knocked more than once?"
"Several times, sir."
"And waited between each fresh summons for an answer?"
"For the answer that never came, sir."
"And after that, you hung about the Square. Can you say for how
long a time?"
"I can't speak with certainty, but I should say I must have been
there altogether quite an hour."
"That brings us to half past three?"
"Yes, sir."
The Juror: "I see your point, Mr. Coroner, but the witness did not
probably possess a watch."
The Coroner: "Have you a watch or a clock in your rooms?"
"No, sir."
"Then your statement as to the time is mere guesswork?"
"No, sir. When I was in Catchpole Square I heard a church clock
strike three."
The Coroner (to a constable): "Do you know if there is an officer
in Court who lives near Catchpole Square?"
The Constable: "I do myself, sir."
The Coroner: "Is there a church close by that tolls the hour?"
The Constable: "Yes, sir, Saint Michael's Church."
The Coroner: "It can be heard in Catchpole Square?"
The Constable: "Quite plainly, sir."
The Coroner: "Thank you." (To Mrs. Death). "You heard the hour
strike when you had been some time in the Square?"
"I must have been there half an hour."
"And you remained some time afterwards?"
"For as long again."
"Are you certain that the church clock struck three?"
"I am, sir. I counted the strokes."
"You did not move out of the Square?"
"No, sir."
"During the whole time you were there was the door of Mr.
Samuel Boyd's house opened?"
"No, sir."
"You did not see any man come from the house, and linger on the
threshold of the door?"
"No, sir."
"At about that hour of three did you observe a sudden flash of
light from an opposite house?"
"No, sir, it was quite dark all the time I was there."
"You are quite positive?"
"Quite positive, sir."
While these questions were asked and answered the spectators in
Court, many of whom had been present while Dr. Pye was giving his
evidence yesterday, held their breath, as it were, and an expression
of intense relief was observable in the countenances of Mr. Reginald
Boyd and his wife and her parents.
The Juror: "Do you think, Mr. Coroner, that the evidence on the
point of time is reliable?"
The Coroner: "As reliable as the evidence of witnesses on other
points."
The Juror: "It is uncorroborated."
The Coroner: "So is the evidence of Dr. Pye, as Mr. Reginald Boyd
remarked."
The Juror: "So is Mr. Reginald Boyd's evidence."
The Coroner: "Exactly." (To Mrs. Death.) "I have no further
questions to ask you."
CHAPTER XLVIII.
THE CORONER'S SUMMING-UP.
"We have now," said the Coroner, addressing the jury, "arrived at
the end of the inquiry, so far as the examination of witnesses is
concerned, and the duty devolves upon you of carefully considering
the evidence, and of giving your verdict. At the opening of this
inquiry I made a strong appeal to you to keep an open mind, and
not to be influenced by the rumours and theories which have been
freely broached by press and public. It is in this way that the
interests of justice will be best served. The case is one of the gravest
import, and your task one of unusual difficulty. For this reason I feel
it my duty to address you at greater length than is usual in inquiries
of this nature.
"There are leading points in the case which we may take as
established beyond dispute. One is that a murder has been
committed, a murder of extreme brutality, and distinguished by
features of extreme cunning. Another, that the man murdered is Mr.
Samuel Boyd. Another, that the murder was committed on the night
of the 1st or the 2nd of March.
"That the crime should have remained undiscovered so long is
due to the peculiar domestic habits of the deceased, and to the facts
that he kept no servants in his house, that he lived quite alone, and
that on the evening of the 1st of March he dismissed the only person
whom he kept regularly employed. Had this dismissal not been
given, and had Mr. Abel Death, his clerk, gone to his work as usual
on the following morning, the discovery of the murder would have
been made within a few hours of its perpetration, and the task
before you would have been rendered far less difficult. I would not
have you attach too much importance to the apparent connection
between the perpetration of the murder and the disappearance of
Mr. Abel Death. Coincidences as strange are not uncommon in
matters less serious, and it is not because this matter is serious that
the coincidence should be construed to the disadvantage of a man
who is absent. Up to Friday, the 1st of March, his relations with his
employer were as fairly satisfactory as could have been expected
from the miserable stipend he received and from the character of
the murdered man, and, unpleasant as those relations became on
that last day, there was nothing in them, so far as we are aware, to
supply a reason for the committal of a deliberate and dastardly
murder, all the details of which must have been carefully planned. If
Mr. Abel Death had been a party to this plan he would hardly have
asked his employer for a loan of ten pounds, a small sum for a rich
man to grant to his confidential clerk.
"For the purpose of arriving, as far as possible, at a clear
comprehension of this part of the mystery let us for a moment follow
the probable movements of Mr. Death on that night.
"He is dismissed from his employment, and he leaves the office, a
disappointed and unhappy man; he relates to his wife all that passed
between him and his employer, and subsequently informs her that
he is going to Catchpole Square to make another appeal to his
employer. I gather that the time of his arrival at the house would be
about ten o'clock, at which hour we may assume that Mr. Samuel
Boyd had not retired to rest. At about nine o'clock Lady Wharton left
Mr. Samuel Boyd at the door of his house, and from that moment all
is mystery. We know, however, that he must have had matters to
attend to which would keep him up a couple of hours. Lady Wharton
had deposited with him a number of valuable jewels, to which, when
she was gone, he would naturally devote attention, appraising them,
and probably taking a list of them. The dismissal of his clerk would
most likely cause him to pay some attention to the state of the
books and accounts, and the jewels had to be put in a place of
safety.
"All this would occupy him a couple of hours, and this brings us to
eleven o'clock, when he would be ready to seek his bed. But before
this hour Mr. Abel Death, according to the theory we are following
out, has paid his visit, or rather, has made his attempt to see his
employer. He knocks at the door, and in response to the summons
Mr. Boyd goes down to see who is there. A man living alone in a
house so safely removed from public observation would be scarcely
likely to open his street door to casual visitors at ten o'clock at night,
nor, the business of the day being over, would he neglect to put the
chain on the street door. His probable course of action would be to
go down, and, opening the door as far as the chain would allow,
inquire who is there. He is answered by Mr. Death, who begs to be
admitted to make his appeal; is refused; while standing in the
square implores to be taken back; is listened to, laughed at, ordered
to go away, and the door shut in his face.
"I do not see how we can carry the matter farther as regards Mr.
Death. To assume that he is admitted to the house, and that Mr.
Boyd went to bed in his presence, is so wildly improbable that we
may at once reject it. If anything can be said to be ridiculous in so
awful a tragedy it would be to suppose that Mr. Boyd thus placed
himself in the power and at the mercy of a man whom he knew to
be embittered against him, and who was in a sense desperate. As to
Mr. Abel Death's subsequent movements we are left in mystery. His
wife suggests foul play. That a man left in the position to which my
argument has carried him should deliberately conceal himself
without a distinct motive is not to be thought of, and for this reason
I consider the suggestion of foul play tenable. From whom, or from
what quarter, who shall say? But we are not here to inquire into this
matter; it is not the fate of Mr. Death we have to deliberate upon,
and I advise you therefore to narrow the issue, which is sufficiently
wide and perplexing, by setting him aside. There is nothing
whatever to connect him with the crime beyond the merest
conjectures, and were he alone concerned the only verdict that
could be returned would be one of 'Murder by some person or
persons unknown.'
"We will now turn to another branch of the subject. In reply to a
question I put to Mrs. Death she expressed her belief that her
husband had no enemies: but a man carrying on such a business as
Mr. Samuel Boyd transacted must have had many. However harsh it
may sound, there is in my mind very little doubt that he must have
inflicted great wrongs upon a number of persons. The tactics
pursued by moneylenders of his class are so tricky and
unscrupulous--they are so entirely oblivious of the claims of common
humanity--that they must perforce breed animosity and resentment
in the breasts of those whom they entrap. I am referring,
understand, to that class of moneylenders whose nefarious practices
have made them a danger to society, and I am happy to see that the
strong arm of the law is being stretched forward to protect the
unwary and unsuspecting victims who fall into their clutches. On the
other hand, there are, of course, among such a man's customers
some crafty borrowers who would trick the moneylender as he
would trick them, men with doubtful reputations whose characters
are no better than his own. It is for your consideration whether Mr.
Samuel Boyd has fallen a victim to a cunningly laid plot on the part
of a band of these men; the abstraction of the books and papers in
which their names would appear favours this presumption. We have
no evidence presented to us that affords a clue to the discovery of
such a plot, but it will be as well not to lose sight of its probable
existence.
"Returning to my argument concerning Mr. Samuel Boyd's
movements within his house on the night in question, we behold him
still alone at about eleven o'clock, his office business finished, the
visit of Mr. Abel Death disposed of, and he preparing for bed. And
here Mr. Reginald Boyd comes into the picture.
"We have heard from his lips his account of what took place
during his interview with his father, and we have to accept or reject
it. They were alone together, there were no witnesses, and we have
only Mr. Reginald Boyd's word to go upon. You must not allow this to
militate against him. In the circumstances of the case it is hardly
possible that there could have been witnesses to corroborate the
account he gave, and I have no hesitation in declaring that his
bearing in the witness box bore the impress of truth. It has been
objected to that in the course of this inquiry private domestic affairs
have been dragged into the light which seemingly had no connection
with it, but painful as this must have been to certain of the
witnesses, it has established more than one point which, in the
opinion of some of you, may be of importance--such, for instance, as
the nature of the relations which existed between Mr. Samuel Boyd
and his son, and the fact that the latter was in extremely straitened
circumstances. I do not think that any blame is to be attached to the
son for having renounced the name of Boyd two years ago, when
the strained relations between him and his father led to his leaving,
or being turned from, his home in Catchpole Square. It is not an
instance without parallel; men have changed their names for
motives less powerful than this. Mr. Reginald Boyd's bearing while
giving his evidence here, was that of a high-spirited, independent
young gentleman, who held in abhorrence the business tactics and
practices of his father, and it is not unnatural, when the connection
was severed, that he should resolve to be quit of a name which
carried with it a disreputable stigma.
"Nor was it unnatural that Mr. Reginald Boyd should have believed
himself to have been tricked out of the fortune his mother left him,
and that, being now a married man, anxious to provide a home for
his wife, he should have made an effort to obtain restitution. In my
reference to these matters I am not wandering from the issue, for
what you have to consider is, not one incident, circumstance, or act,
apart from the others, but all the incidents, circumstances, and acts
in relation to each other. What in the former case may seem
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!
ebookname.com

More Related Content

PDF
Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent
PDF
Agile Web Development With Rails Third Edition Third Ruby Sam
PPTX
Learning Web Development with Ruby on Rails Launch
PDF
Sustainable Web Development With Ruby On Rails Practical Tips For Building We...
PDF
Rails Cookbook
PDF
Pragmatic Agile Web Development With Rails.3rd Edition.2009
 
PDF
The Birth and Evolution of Ruby on Rails
PDF
Ruby Rails Web Development.pdf
Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent
Agile Web Development With Rails Third Edition Third Ruby Sam
Learning Web Development with Ruby on Rails Launch
Sustainable Web Development With Ruby On Rails Practical Tips For Building We...
Rails Cookbook
Pragmatic Agile Web Development With Rails.3rd Edition.2009
 
The Birth and Evolution of Ruby on Rails
Ruby Rails Web Development.pdf

Similar to Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent (20)

PDF
Rails4 Days
PDF
Ruby on Rails 3.1: Let's bring the fun back into web programing
PDF
Ruby Rails Web Development
PDF
Ruby Rails Web Development
KEY
Supa fast Ruby + Rails
PDF
RubyOnRails-Cheatsheet-BlaineKendall
PDF
RubyOnRails-Cheatsheet-BlaineKendall
PDF
www.webre24h.com - [O`reilly] javascript cookbook - [powers]
PDF
Javascript Web Applications Otx Alex Maccaw
PDF
Ruby On Rails
PDF
Learning Web App Development 1st Edition Semmy Purewal
PDF
Practical Rails Projects Experts Voice 1st Ed Alameda Eldon
PPT
Ruby On Rails Siddhesh
PDF
Backbonetutorials
PDF
Web application intro + a bit of ruby (revised)
PDF
td_mxc_rubyrails_shin
PDF
td_mxc_rubyrails_shin
PPTX
Session 1 - Getting Started With Rails.pptx
PDF
How to Teach Yourself to Code
PDF
Ruby on rails online training
Rails4 Days
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby Rails Web Development
Ruby Rails Web Development
Supa fast Ruby + Rails
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
www.webre24h.com - [O`reilly] javascript cookbook - [powers]
Javascript Web Applications Otx Alex Maccaw
Ruby On Rails
Learning Web App Development 1st Edition Semmy Purewal
Practical Rails Projects Experts Voice 1st Ed Alameda Eldon
Ruby On Rails Siddhesh
Backbonetutorials
Web application intro + a bit of ruby (revised)
td_mxc_rubyrails_shin
td_mxc_rubyrails_shin
Session 1 - Getting Started With Rails.pptx
How to Teach Yourself to Code
Ruby on rails online training
Ad

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Institutional Correction lecture only . . .
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Computing-Curriculum for Schools in Ghana
PDF
01-Introduction-to-Information-Management.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Basic Mud Logging Guide for educational purpose
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Lesson notes of climatology university.
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Classroom Observation Tools for Teachers
Complications of Minimal Access Surgery at WLH
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Institutional Correction lecture only . . .
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
Computing-Curriculum for Schools in Ghana
01-Introduction-to-Information-Management.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Basic Mud Logging Guide for educational purpose
102 student loan defaulters named and shamed – Is someone you know on the list?
Lesson notes of climatology university.
Cell Structure & Organelles in detailed.
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Classroom Observation Tools for Teachers
Ad

Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent

  • 1. Learning Rails 3 Rails from the Outside In 1st Edition Simon St. Laurent download https://ebookname.com/product/learning-rails-3-rails-from-the- outside-in-1st-edition-simon-st-laurent/ Get Instant Ebook Downloads – Browse at https://ebookname.com
  • 2. Instant digital products (PDF, ePub, MOBI) available Download now and explore formats that suit you... Rails Recipes Rails 3 Edition Chad Fowler https://ebookname.com/product/rails-recipes-rails-3-edition-chad- fowler/ Rails 4 in Action Revised Edition of Rails 3 in Action Ryan Bigg https://ebookname.com/product/rails-4-in-action-revised-edition- of-rails-3-in-action-ryan-bigg/ Introducing Elixir Getting Started in Functional Programming 2nd Edition Simon St. Laurent https://ebookname.com/product/introducing-elixir-getting-started- in-functional-programming-2nd-edition-simon-st-laurent/ Carbon Nanotubes and Related Structures Peter J. F. Harris https://ebookname.com/product/carbon-nanotubes-and-related- structures-peter-j-f-harris/
  • 3. Ethernet Networks Design Implementation Operation Management 4th Edition Gilbert Held https://ebookname.com/product/ethernet-networks-design- implementation-operation-management-4th-edition-gilbert-held/ The Language of Psychoanalysis First Edition Laplanche https://ebookname.com/product/the-language-of-psychoanalysis- first-edition-laplanche/ Somebody Better Page Turners Level 1 1st Edition Julian Thomlinson https://ebookname.com/product/somebody-better-page-turners- level-1-1st-edition-julian-thomlinson/ Death by a Thousand Cuts The Fight over Taxing Inherited Wealth 1st Edition Michael J. Graetz https://ebookname.com/product/death-by-a-thousand-cuts-the-fight- over-taxing-inherited-wealth-1st-edition-michael-j-graetz/ Regret Developmental Cultural and Clinical Realms 1st Edition Salman Akhtar https://ebookname.com/product/regret-developmental-cultural-and- clinical-realms-1st-edition-salman-akhtar/
  • 4. China Building an Innovative Economy 1st Edition Celeste Varum https://ebookname.com/product/china-building-an-innovative- economy-1st-edition-celeste-varum/
  • 7. Learning Rails 3 Simon St.Laurent, Edd Dumbill, and Eric J. Gruber Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo
  • 8. Learning Rails 3 by Simon St.Laurent, Edd Dumbill, and Eric J. Gruber Copyright © 2012 Simon St.Laurent, Edd Dumbill, Eric J. Gruber. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Editor: Simon St.Laurent Production Editor: Iris Febres Proofreader: Jasmine Perez Indexer: Lucie Haskins Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrators: Robert Romano, Rebecca Demarest, and Jessamyn Read July 2012: First Edition. Revision History for the First Edition: 2012-07-11 First release See http://oreilly.com/catalog/errata.csp?isbn=9781449309336 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Learning Rails 3, the image of the tarpans, and related trade dress are trademarks of O’Reilly Media, Inc. 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 O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein. ISBN: 978-1-449-30933-6 [M] 1342467902
  • 9. Table of Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi 1. Starting Up Ruby on Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 If You Run Windows, You’re Lucky 2 Getting Started at the Command Line 3 Starting Up Rails 8 Test Your Knowledge 9 Quiz 9 Answers 9 2. Rails on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Creating Your Own View 11 What Are All Those Folders? 14 Adding Some Data 16 How Hello World Works 18 Adding Logic to the View 20 Test Your Knowledge 22 Quiz 22 Answers 22 3. Adding Web Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 I Want My CSS! 23 Specifying Stylesheets 28 Creating a Layout for a Controller 29 Choosing a Layout from a Controller 31 Sharing Template Data with the Layout 33 Setting a Default Page 34 Test Your Knowledge 36 Quiz 36 Answers 36 iii
  • 10. 4. Managing Data Flow: Controllers and Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Getting Started, Greeting Guests 37 Application Flow 42 Keeping Track: A Simple Guestbook 44 Connecting to a Database Through a Model 44 Connecting the Controller to the Model 47 Finding Data with ActiveRecord 52 Test Your Knowledge 54 Quiz 54 Answers 54 5. Accelerating Development with Scaffolding and REST . . . . . . . . . . . . . . . . . . . . . . . . 57 A First Look at Scaffolding 57 REST and Controller Best Practices 61 Websites and Web Applications 61 Toward a Cleaner Approach 63 Examining a RESTful Controller 64 Index: An Overview of Data 69 Show: Just One Row of Data 71 New: A Blank Set of Data Fields 71 Edit: Hand Me That Data, Please 72 Create: Save Something New 72 Put This Updated Record In 74 Destroy It 75 Escaping the REST Prison 76 Test Your Knowledge 76 Quiz 76 Answers 77 6. Presenting Models with Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 More Than a Name on a Form 79 Generating HTML Forms with Scaffolding 80 Form as a Wrapper 84 Creating Text Fields and Text Areas 87 Labels 89 Creating Checkboxes 90 Creating Radio Buttons 91 Creating Selection Lists 93 Dates and Times 95 Creating Helper Methods 97 Test Your Knowledge 100 Quiz 100 Answers 100 iv | Table of Contents
  • 11. 7. Strengthening Models with Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Without Validation 103 The Original Model 106 The Power of Declarative Validation 106 Managing Secrets 109 Customizing the Message 109 Limiting Choices 111 Testing Format with Regular Expressions 112 Seen It All Before 112 Numbers Only 113 A Place on the Calendar 114 Testing for Presence 115 Beyond Simple Declarations 115 Test It Only If 115 Do It Yourself 116 Test Your Knowledge 117 Quiz 117 Answers 117 8. Improving Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Adding a Picture by Uploading a File 119 File Upload Forms 120 Model and Migration Changes 120 Results 126 Standardizing Your Look with Form Builders 129 Supporting Your Own Field Types 130 Adding Automation 132 Integrating Form Builders and Styles 134 Test Your Knowledge 137 Quiz 137 Answers 138 9. Developing Model Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Connecting Awards to Students 140 Establishing the Relationship 140 Supporting the Relationship 141 Guaranteeing a Relationship 145 Connecting Students to Awards 146 Removing Awards When Students Disappear 146 Counting Awards for Students 147 Nesting Awards in Students 148 Changing the Routing 149 Changing the Controller 150 Table of Contents | v
  • 12. Changing the Award Views 153 Connecting the Student Views 156 Is Nesting Worth It? 158 Many-to-Many: Connecting Students to Courses 159 Creating Tables 159 Connecting the Models 161 Adding to the Controllers 162 Adding Routing 164 Supporting the Relationship Through Views 164 What’s Missing? 172 Test Your Knowledge 172 Quiz 172 Answers 173 10. Managing Databases with Migrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 What Migrations Offer You 175 Migration Basics 176 Migration Files 177 Running Migrations Forward and Backward 178 Inside Migrations 180 Working with Tables 181 Data Types 181 Working with Columns 183 Indexes 183 Other Opportunities 184 Test Your Knowledge 185 Quiz 185 Answers 185 11. Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Creating Your Own Debugging Messages 187 Raising Exceptions 188 Logging 188 Working with Rails from the Console 190 The Ruby Debugger 195 Test Your Knowledge 199 Quiz 199 Answers 199 12. Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Test Mode 201 Setting Up a Test Database with Fixtures 202 Unit Testing 206 vi | Table of Contents
  • 13. Functional Testing 212 Calling Controllers 214 Testing Responses 215 Dealing with Nested Resources 216 Integration Testing 218 Beyond the Basics 220 Test Your Knowledge 221 Quiz 221 Answers 221 13. Sessions and Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Getting Into and Out of Cookies 223 Storing Data Between Sessions 230 Test Your Knowledge 235 Quiz 235 Answers 235 14. Users and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 Installation 237 Storing Identities 239 Storing User Data 239 Wiring OmniAuth into the Application 240 Classifying Users 248 More Options 255 Test Your Knowledge 256 Quiz 256 Answers 256 15. Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Creating Routes to Interpret URIs 258 Specifying Routes with match 258 Globbing 260 Regular Expressions and Routing 261 A Domain Default with root 261 Named Routes 262 Mapping Resources 263 Nesting Resources 264 Route Order and Priority 265 Checking the Map 265 Generating URIs from Views and Controllers 266 Pointing url_for in the Right Direction 266 Adding Options 267 Infinite Possibilities 267 Table of Contents | vii
  • 14. Test Your Knowledge 268 Quiz 268 Answers 268 16. From CSS to SASS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Getting Started 271 Sassy Style 272 Variables 272 Mixins 274 Nesting 275 Making Everything Work Together 276 Becoming Sassier 279 Test Your Knowledge 280 Quiz 280 Answers 280 17. Managing Assets and Bundles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 The Junk Drawer 281 Sprockets 282 Dissecting The Pipeline 283 Putting It All Together 283 Bundler 286 Test Your Knowledge 290 Quiz 290 Answers 290 18. Sending Code to the Browser: JavaScript and CoffeeScript . . . . . . . . . . . . . . . . . . . 291 Sending JavaScript to the Browser 292 Simplifying with CoffeeScript 293 Have Some Sugar with your CoffeeScript 295 Converting to CoffeeScript 297 Test Your Knowledge 298 Quiz 298 Answers 298 19. Mail in Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Sending Mail Messages 299 Receiving Mail 304 Setup 305 Processing Messages 305 Test Your Knowledge 308 Quiz 308 Answers 308 viii | Table of Contents
  • 15. 20. Pushing Further into Rails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 Changing to Production Mode 309 Deploying Is Much More Than Programming 310 Joining the Rails Ecosystem 313 Keep Up with Rails 313 Ruby 313 Working With and Around Rails 314 Keep Exploring 314 A. An Incredibly Brief Introduction to Ruby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 B. An Incredibly Brief Introduction to Relational Databases . . . . . . . . . . . . . . . . . . . . 335 C. An Incredibly Brief Guide to Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 D. Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 Table of Contents | ix
  • 17. Preface Everyone cool seems to agree: Ruby on Rails is an amazing way to build web applications. Ruby is a powerful and flexible programming language, and Rails takes advantage of that flexibility to build a web application framework that takes care of a tremendous amount of work for the developer. Everything sounds great! Except, well… all the Ruby on Rails books talk about this “Model-View-Controller” thing, and they start deep inside the application, close to the database, most of the time. From an experienced Rails developer’s perspective, this makes sense—the framework’s power lies largely in making it easy for developers to create a data model quickly, layer controller logic on top of that, and then, once all the hard work is done, put a thin layer of interface view on the very top. It’s good programming style, and it makes for more robust applications. Advanced Ajax functionality seems to come almost for free! From the point of view of someone learning Ruby on Rails, however, that race to show off Rails’ power can be extremely painful. There’s a lot of seemingly magical behavior in Rails that works wonderfully—until one of the incantations isn’t quite right and figuring out what happened means unraveling all that work Rails did. Rails certainly makes it easier to work with databases and objects without spending forever thinking about them, but there are a lot of things to figure out before that ease becomes obvious. If you’d rather learn Ruby on Rails more slowly, starting from pieces that are more familiar to the average web developer and then moving slowly into controllers and models,you’reintherightplace.YoucanstartfromtheHTMLyoualreadylikelyknow, and then move more deeply into Rails’ many interlinked components. This updated version of Learning Rails covers version 3.2. There are substantial changes from earlier versions. Rails itself keeps changing, even in ways that affect beginners. Who This Book Is For You’ve probably been working with the Web for long enough to know that writing web applications always seems more complicated than it should be. There are lots of parts xi
  • 18. to manage, along with lots of people to manage, and hopefully lots of visitors to please. Ruby on Rails has intrigued you as one possible solution to that situation. You may be a designer who’s moving toward application development or a developer who combines some design skills with some programming skills. You may be a programmer who’s familiar with HTML but who lacks the sense of grace needed to create beautiful design—that’s a fair description of one of the authors of this book, anyway. Wherever you’re from, whatever you do, you know the Web well and would like to learn how Rails can make your life easier. The only mandatory technical prerequisite for reading this book is direct familiarity with HTML and a general sense of how programming works. You’ll be inserting Ruby codeintothatHTMLasafirststeptowardwritingRubycodedirectly,sounderstanding HTML is a key foundation. (If you don’t know Ruby at all, you probably want to look over Appendix A or at least keep it handy for reference.) Cascading Style Sheets (CSS) will help you make that HTML look a lot nicer, but it’s not necessary for this book. Similarly, a sense of how JavaScript works may help. Experience with other templating languages (like PHP, ASP, and ASP.NET) can also help, but it isn’t required. You also need to be willing to work from the command line sometimes. The commands aren’t terribly complicated, but they aren’t (yet) completely hidden behind a graphical interface. Who This Book Is Not For We don’t really want to cut anyone out of the possibility of reading this book, but there are some groups of people who aren’t likely to enjoy it. Model-View-Controller purists will probably grind their teeth through the first few chapters, and people who insist that data structures are at the heart of a good application are going to have to wait an even longer time to see their hopes realized. If you consider HTML just a nuisance that programmers have to put up with, odds are good that this book isn’t for you. Most of the other Ruby on Rails books, though, are written for people who want to start from the model! Also, people who are convinced that Ruby and Rails are the one true way may have some problems with this book, which spends a fair amount of time warning readers about potential problems and confusions they need to avoid. Yes, once you’ve worked with Ruby and Rails for a while, their elegance is obvious. However, reaching that level of comfort and familiarity is often a difficult road. This book attempts to ease as many of those challenges as possible by describing them clearly. xii | Preface
  • 19. What You’ll Learn Building a Ruby on Rails application requires mastering a complicated set of skills. You may find that—depending on how you’re working with it, and who you’re working with—you only need part of this tour. That’s fine. Just go as far as you think you’ll need. At the beginning, you’ll need to install Ruby on Rails. We’ll explore different ways of doing this, with an emphasis on easier approaches to getting Ruby and Rails operational. Next, we’ll create a very simple Ruby on Rails application, with only a basic view and then a controller that does a very few things. From this foundation, we’ll explore ways to create a more sophisticated layout using a variety of tools, learning more about Ruby along the way. Once we’ve learned how to present information, we’ll take a closer look at controllers and what they can do. Forms processing is critical to most web applications, so we’ll build a few forms and process their results, moving from the simple to the complex. Forms can do interesting things without storing data, but after a while it’s a lot more fun to have data that lasts for more than just a few moments. The next step is setting up a database to store information and figuring out how the magic of Rails’ ActiveRecord makes it easy to create code that maps directly to database structures— without having to think too hard about database structures or SQL. Once we have ActiveRecord up and running, we’ll explore scaffolding and its possi- bilities. Rails scaffolding not only helps you build applications quickly, it helps you learn to build them well. The RESTful approach that Rails emphasizes will make it simpler for you to create applications that are both attractive and maintainable. For purposes of illustration, using scaffolding also makes it easier to demonstrate one task at a time, which we hope will make it easier for you to understand what’s happening. Ideally, at this point, you’ll feel comfortable with slightly more complicated data mod- els, and we’ll take a look at applications that need to combine data in multiple tables. Mixing and matching data is at the heart of most web applications. We’ll also take a look at testing and debugging Rails code, a key factor in the frame- work’s success. Migrations, which make it easy to modify your underlying data structures (and even roll back those changes if necessary), are another key part of Rails’ approach to application maintainability. The next step will be to add some common web applications elements like sessions and cookies, as well as authentication. Rails (with the help of gems for authentication) can manage a lot of this work for you. We’ll also let Rails stretch its legs a bit, showing off its recent support for Syntactically Awesome Stylesheets (Sass), CoffeeScript scripting, bundle management, and sending email messages. Preface | xiii
  • 20. By the end of this tour, you should be comfortable with working in Ruby on Rails. You may not be a Rails guru yet, but you’ll be ready to take advantage of all of the other resources out there for becoming one. Ruby and Rails Style It’s definitely possible to write Ruby on Rails code in ways that look familiar to programmers from other languages. However, that code often isn’t really idiomatic Ruby, as Ruby programmers have chosen other paths. In general, this book will always try to introduce new concepts using syntax that’s likely to be familiar to developers from other environments, and then explain what the local idiom does. You’ll learn to write idiomatic Ruby that way (if you want to), and at the same time you’ll figure out how to read code from the Ruby pros. We’ve tried to make sure that the code we present is understandable to those without a strong background in Ruby. Ruby itself is worth an introductory book (or several), but the Ruby code in a lot of Rails applications is simple, thanks to the hard work the framework’s creators have already put into it. You may want to install Rails in Chap- ter 1, and then explore Appendix: “An Incredibly Brief Introduction to Ruby” before diving in. Other Options There are lots of different ways to learn Rails. Some people want to learn Ruby in detail before jumping into a framework that uses it. That’s a perfectly good option, and if you want to start that way, you should explore the following books: • Learning Ruby by Michael Fitzgerald (O’Reilly, 2007) • The Ruby Programming Language by David Flanagan and Yukhiro Matsumoto (O’Reilly, 2008) • Ruby Pocket Reference by Michael Fitzgerald (O’Reilly, 2007) • Programming Ruby, Third Edition by Dave Thomas with Chad Fowler and Andy Hunt (Pragmatic Programmers, 2008) • The Well-Grounded Rubyist by David A. Black (Manning, 2009) • Eloquent Ruby by Russ Olsen (Addison-Wesley, 2011) • Metaprogramming Ruby by Paolo Perrotta (Pragmatic Programmers, 2010) You may also want to supplement (or replace) this book with other books on Rails. If you want some other resources, you can explore: • For maximum excitement, try http://railsforzombies.com/, a training tool that includes video and exercises. xiv | Preface
  • 21. • Try http://railscasts.com/ for all kinds of detailed programming demonstrations in a video format. • Ruby on Rails 3 Tutorial by Michael Hartl (Addison-Wesley, 2010), provides a faster-moving introduction that covers many more extensions for Rails. • The Rails 3 Way by Obie Fernandez (Addison-Wesley, 2010), takes a big-book reference approach for developers who already know their way. • Agile Web Development with Rails, Fourth Edition, (Pragmatic Programmers, 2010), by Sam Ruby, Dave Thomas, and David Heinemeier Hansson gives a de- tailed explanation of a wide range of features. Ideally, you’ll want to make sure that whatever books or online documentation you use cover at least Rails 3.0 (or later). Rails’ perpetual evolution has unfortunately made it dangerous to use a lot of formerly great but now dated material (some of it works, some of it doesn’t). Finally, key resources you should always explore are the Ruby on Rails Guides (http:// guides.rubyonrails.org/), which provide an excellent and well-updated overview for a lot of common topics. Sometimes they leave gaps or demand more background knowledge than beginners have, but they’re a wonderful layer of documentation at a level above the basic (though also useful) API documentation at http://api.rubyonrails .org/. Rails Versions The Rails team is perpetually improving Rails and releasing new versions. This book was updated for Rails 3.2.3 and Ruby 1.9.2. If You Have Problems Making Examples Work When you’re starting to use a new framework, error messages can be hard, even impossible, to decipher. We’ve included occasional notes in the book about particular errorsyoumight see,but it seemsverynormal for different peopletoencounterdifferent errors as they work through examples. Sometimes it’s the result of skipping a step or entering code just a little differently than it was in the book. It’s probably not the result of a problem in Rails itself, even if the error message seems to come from deep in the framework. That isn’t likely an error in the framework, but much more likely a problem the framework is having in figuring out how to deal with the unexpected code it just encountered. If you find yourself stuck, here are a few things you should check: What version of Ruby are you running? You can check by entering ruby -v. All of the examples in this book were written with Ruby 1.9.2. You can also use Ruby 1.8.7 with Rails, but many of the examples Preface | xv
  • 22. here (especially those using hashes) may not always work for you. Versions of Ruby older than 1.8.7 may cause problems for Rails 3.x, and even version 1.9.1 of Ruby causes problems. Chapter 1 explores how to install Ruby, but you may need to find documentation specific to your specific operating system and environment. What version of Rails are you running? You can check by running rails -v. You might think that you should be able to use the examples here with any version of Rails 3.x, but Rails keeps changing in ways that break even simple code even among the 3.x versions. The examples on the book’s site include a number of versions from Rails 2.1 to Rails 3.2. If you’re running a version of Rails other than 3.2, especially an earlier version, you will encounter problems. Are you calling the program the right way? Linux and Mac OS X both use a forward slash, /, as a directory separator, whereas Windows uses a backslash, . This book uses the forward slash, but if you’re in Windows, you may need to use the backslash. Leaving out an argument can also produce some really incomprehensible error messages. Is the database connected? By default, Rails expects you to have SQLite up and running, though some instal- lations use MySQL or other databases. If you’re getting errors that have “sql” in them somewhere, it’s probably the database. Check that the database is installed and running, that the settings in database.yml are correct, and that the permissions, if any, are set correctly. Are all of the pieces there? Most of the time, assembling a Rails application, even a simple one, requires modifying multiple files—at least a view and a controller. If you’ve only built a controller, you’re missing a key piece you need to see your results; if you’ve only built a view, you need a controller to call it. As you build more and more complex applications, you’ll need to make sure you’ve considered routing, models, and maybe even configuration and plug-ins. What looks like a simple call in one part of the application may depend on pieces elsewhere. Eventually, you’ll know what kinds of problems specific missing pieces cause, but at least at first, try to make sure you’ve entered complete examples before running them. It’s also possible to have files present but with the wrong permissions set. If you know a file is there, but Rails can’t seem to get to it, check to make sure that permissions are set correctly. Did you save all the files? Of course this never happens to you. However, making things happen in Rails often means tinkering with multiple files at the same time, and it’s easy to forget to save one as you move along. This can be especially confusing if it was a configuration or migration file. Always take a moment to make sure everything you’re editing has been saved before trying to run your application. xvi | Preface
  • 23. Are your routes right? If you can’t get a page to come up, you probably have a problem with your routes. This is a more common problem when you’re creating controllers directly, as you will be up through Chapter 4, rather than having Rails generate scaffolding. Check config/routes.rb. Is everything named correctly? Rails depends on naming conventions to establish connections between data and code without you having to specify them explicitly. This works wonderfully, until you have a typo somewhere obscure. Rails also relies on a number of Ruby con- ventions for variables, prefacing instance variables with @ or symbols with :. These special characters make a big difference, so make sure they’re correct. Is the Ruby syntax right? If you get syntax errors, or sometimes even if you get a nil object error, you may have an extra space, missing bracket, or similar issue. Ruby syntax is extremely flexible, so you can usually ignore the discipline of brackets, parentheses, or spaces—but sometimes it really does matter. Is another Rails app running? Jumping quickly between programs can be really confusing. In a normal develop- ment cycle, you’ll just have one app running, and things just work. When you’re reading a book, especially if you’re downloading the examples, it’s easy to start an app, close the window you use to explore it, and forget it’s still running underneath. Definitely stop one server before running another while you’re exploring the apps in this book. Are you running the right program? Yes, this sounds weird. When you’re developing real programs, it makes sense to leave the server running to check back and forth with your changes. If you’re testing out a lot of small application examples quickly, though, you may have problems. Definitely leave the server running while you’re working within a given example, but stop it when you change chapters or set off to create a new application with the rails command. Does your model specify attr_accessible? Rails tightened its security rules in Rails 3.2, requiring that models include an attr_accessible declaration at the start, identifying which fields can be reached through Rails. Older code, even code from earlier versions of this book, generally didn’t do this. If you get error messages like “Can’t mass-assign protected attributes,” this is likely the problem. Did the authors just plain screw up? Obviously, we’re working hard to ensure that all of the code in this book runs smoothly the first time, but it’s possible that an error crept through. You’ll want to check the errata, described in the next section, and download sample code, which will be updated for errata. Preface | xvii
  • 24. It’s tempting to try Googling errors to find a quick fix. Unfortunately, the issues just described are more likely to be the problem than something else that has clear documentation. The Rails API documentation (http://api.rubyonrails.org/) might be helpful at times, especially if you’re experimenting with extending an example. There shouldn’t be much out there, though, beyond the book example files themselves that you can download to fix an example. If You Like (or Don’t Like) This Book If you like—or don’t like—this book, by all means, please let people know. Amazon reviews are one popular way to share your happiness (or lack of happiness), or you can leave reviews on the site for this book: http://www.oreilly.com/catalog/9781449309336/ There’s also a link to errata there. Errata gives readers a way to let us know about typos, errors, and other problems with the book. The errata will be visible on the page immediately, and we’ll confirm it after checking it out. O’Reilly can also fix errata in future printings of the book and on Safari, making for a better reader experience pretty quickly. We hope to keep this book updated for future versions of Rails and will also incorporate suggestions and complaints into future editions. Conventions Used in This Book The following font conventions are used in this book: Italic Indicates pathnames, filenames, and program names; Internet addresses, such as domain names and URLs; and new items where they are defined. Constant width Indicates command lines and options that should be typed verbatim; names and keywords in programs, including method names, variable names, and class names; and HTML element tags. Constant width bold Indicates emphasis in program code lines. Constant width italic Indicates text that should be replaced with user-supplied values. This icon signifies a tip, suggestion, or general note. xviii | Preface
  • 25. This icon indicates a warning or caution. Using Code Examples The code examples for this book, which are available from http://oreil.ly/Learning Rails3, come in two forms. One is a set of examples, organized by chapter, with each example numbered and named. These examples are referenced from the relevant chap- ter. The other form is a dump of all the code from the book, in the order it was presented in the book. That can be helpful if you need a line that didn’t make it into the final example, or if you want to cut and paste pieces as you walk through the examples. Hopefully, the code will help you learn. So far, the code examples for this electronic version of the book have stayed in sync with the code examples for the print book, updated for errata. This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning Rails 3 by Simon St.Laurent, Edd Dumbill, and Eric J. Gruber. Copyright 2012 Simon St.Laurent, Edd Dumbill, and Eric Gruber, 978-1-449-30933-6.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com. Safari® Books Online Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business. Technology professionals, software developers, web designers, and business and cre- ative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training. Safari Books Online offers a range of product mixes and pricing programs for organi- zations, government agencies, and individuals. Subscribers have access to thousands Preface | xix
  • 26. of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison- Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online. How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at: http://oreil.ly/LearningRails3 To comment or ask technical questions about this book, send email to: bookquestions@oreilly.com For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com. Find us on Facebook: http://facebook.com/oreilly Follow us on Twitter: http://twitter.com/oreillymedia Watch us on YouTube: http://www.youtube.com/oreillymedia Acknowledgments Thanks to Mike Loukides for thinking that Rails could use a new and different ap- proach, and for supporting this project along the way. Tech reviewers Gregg Pollack, Shelley Powers, Mike Fitzgerald, Eric Berry, David Schruth, Mike Hendrickson, and Mark Levitt all helped improve the first edition of the book tremendously. For this edition, Aaron Sumner, David DeMello, and Alan Harris went through the details carefully, finding many changes we’d overlooked and making helpful suggestions. The rubyonrails-talk group providedregularinspiration,asdidthe screencastsandpodcasts at http://railscasts.com/. xx | Preface
  • 27. Edd Dumbill wishes to thank his lovely children, Thomas, Katherine, and Peter, for bashing earnestly on the keyboard, and his coauthor, Simon St.Laurent, for his patient encouragement in writing this book. Simon St.Laurent wants to thank Angelika St.Laurent for her support over the course of writing this, even when it interfered with dinner, and Sungiva and Konrad St.Laurent for their loudly shouted suggestions. Simon would also like to thank Edd Dumbill for his initial encouragement and for making this book possible. Eric would like to thank his lovely wife for enduring many late-night endeavors to learn about this wonderful world of code, his parents and sister for always encouraging him to find his own path, his community of designers and developers in the Lawrence area, Aaron Sumner for being a patient guide in the Ruby world, and his children, who inspire him to learn how to code well enough to teach it to them (if that’s what they want). We’d all like to thank Jasmine Perez for cleaning up our prose, Iris Febres for getting this book through production, and Lucie Haskins for the patient work it takes to build an index. Preface | xxi
  • 29. CHAPTER 1 Starting Up Ruby on Rails Before you can use Rails, you have to install it. Even if it’s already installed on your computer, you may need to consider upgrading it. In this chapter, we’ll take a look at some ways of installing Ruby, Rails, and the supporting infrastructure. Please feel very welcome to jump to whatever pieces of this section interest you and skip past those that don’t. Once the software is working, we’ll generate the basic Rails application, which will at least let you know if Rails is working. However you decide to set up Rails, in the end you’re going to have a structure like that shown in Figure 1-1. Figure 1-1. The many components of a Rails installation 1
  • 30. Discovering Diverse Content Through Random Scribd Documents
  • 31. contemplated Mr. Higgins, and in a mocking tone that he repeated for the second time, "Such a very honest tradesman as Mr. Higgins! Get on, will you? You left off where you'd been having all the papers read to you." That the doubt as to the success of his enterprise which Dick's independent manner had introduced was not lessened was apparent, for though what he said was pregnant enough his tone lost something of its confidence. "Yes, I gets 'em all read out to me, and it sets me thinking. 'What call has Mr. Dick Remington got to keep it dark?' says I to myself. 'Why don't he say nothing about it? There's something in the wind. He comes to my shop, and buys a rope and grapnel in a secret sort o' way'--" "Wrong, my honest tradesman," interrupted Dick, and Mr. Higgins shifted uneasily in his chair, "I bought it openly. Did I ask you to keep it dark?" "No, you didn't, but did you go out of my shop with the rope hanging over your arm?' O-ho!' says I, 'here's a working man ashamed to carry a rope. He asks for a bit of paper to wrap it up in, he does, and he puts it under his coat, he does. That's a rum sort o' working man,' says I." "Clever Mr. Higgins," said Dick, patronisingly, "clever Mr. Higgins!" "Do you mean to tell me," said that worthy, driven to exasperation by Dick's coolness, "that you didn't use it to get over the wall at the back of Samuel Boyd's house in Catchpole Square, that it wasn't you as broke the kitchen winder, that you didn't break open the safe--" "Hold hard," said Dick, "you've had the papers read wrong. The safe was not broken open."
  • 32. "What does that matter?" snarled Mr. Higgins. "Broke open, or opened with a key, it's all the same. The man as did it helped hisself to the money and jewels, and made off with the swag--with my rope and grapnel that cost me its weight in gold--how does that strike you, Mr. Dick?" "You old fool," said Dick, with a broad smile, "if you knock your head against that brick wall you'll knock out the few brains you possess. If you think I can't reckon up an honest tradesman like you, you were never more mistaken in your life." And with the forefinger of his right hand he tapped the side of his nose, and winked at Mr. Higgins. But though he spoke and acted thus boldly he fully recognised the seriousness of this new danger. Say that this man laid information against him at the first police station; say that it got to the knowledge of Detective Lambert who was searching everywhere for a clue to the mystery. What would be the consequence? A warrant would be immediately issued for his arrest, and a search warrant as well. The rope and grapnel, tied up in brown paper, was now under the bed of his room in Constable Pond's house, and the key of that room was in his pocket. How could he explain away his possession of the rope? He would be asked why he made no mention of it at the inquest; his silence regarding it would be a piece of damning evidence against him. And not the only piece. His prowling about in the neighbourhood of Catchpole Square at an early hour of the morning, as testified by Constable Applebee, was in the highest degree suspicious when taken in connection with his possession of the rope and grapnel. His knowledge of the habits of Samuel Boyd, gained during his employment as clerk in the house, would be against him. One thing was certain. He would be deprived of his liberty, and the contemplation of this contingency filled him with dismay. Everything depended upon his being free to carry out the plans he had formed, and therefore upon his turning the tables upon the old vagabond who sat leering into his face.
  • 33. And in the event of his being arrested, what would be said of him in Aunt Rob's home? Was it not probable, aye, more than probable, that they would suspect him to be the murderer? He had woven a net for himself, and if he were not careful he would drag down Reginald with him. Press and public would say "collusion," and the chain of circumstantial evidence be too strong for him to break through. Admitting all this, he felt that any sign of weakness in the presence of Mr. Higgins would be fatal. There was nothing for it but to play the bold game. "I've a good mind," he said, slowly and sternly, "to go and give information against you." "What do you mean?" demanded Mr. Higgins, his features twitching more hideously than ever. Dick hailed these signs of discomposure with delight, and encouraged by the impression his sarcastic references to Mr. Higgins as an honest tradesman had produced he was quick to take advantage of it. He resembled the gambler who stakes his whole fortune upon the last throw. "Did you ever see the secret books of the police," he said, "with the names of certain men with black marks against them? Why, we can lay our hands upon every thief and fence in London when we want to--do you hear? when we want to." Mr. Higgins winced. "There are some things that lick us for a time, like this Catchpole Square Mystery, but we don't go to sleep over them, though some people may think we do. And when we're playing a high game we don't show our cards. What I mean is, that we'll have your place searched for stolen goods. How will that suit you, my honest tradesman? We can bring one or two things against you that you'll find it hard to explain when you're in the dock. If we let you alone it's because you're not worth the powder and shot, but get our dander up, Mr. Higgins, and we'll make short work of you. How does
  • 34. that suit your book? Take care of your precious self, my man, and let sleeping dogs lie." It was vague, but effective, and it was Dick's good fortune that the hazardous shot told. Indeed, it had gone straight to the bull's eye. Many were the questionable transactions in which, from time to time, Mr. Higgins had been engaged. Petty thieves in the neighbourhood were in the habit of selling their small spoils across his counter; this modern Fagin was always ready to buy, and no questions asked. He had been in trouble more than once, and was in mortal dread of getting into trouble again. This, of course, was unknown to Dick, and it was only from his familiarity with the nature of much of the business transacted in some of these second-hand shops in mean streets that he had ventured upon the bold attack. He could have hugged himself when he saw the effect it produced upon Mr. Higgins. "There is nothing like a good understanding in these matters, Mr. Higgins," he continued, "and I've no wish to be hard on you. I've got my own game to play, and it's keeping me pretty busy. Between ourselves--don't be frightened, there's nobody by--I did purchase a rope and grapnel of you, but is it for you to say whether I purchased it for myself or for another person, and what use I made of it? I might deny it if I chose, and then, my honest tradesman, who would take your word against mine? Is there any magistrate's court in London where your oath would be believed, much less your word? What a blind fool you are! Upon my word I gave you credit for more sense. Perhaps the reporter of 'The Little Busy Bee' used a rope and grapnel, perhaps he didn't. Perhaps it was the one I bought of you, perhaps it wasn't. I'm not going to let you into the know, Mr. Higgins. How would you like to have the papers down on you as well as the police? How do you know I'm not acting under instructions to track and catch the murderer or murderers of Samuel Boyd? How do you know"--here he leaned forward, and tapped Mr. Higgins confidentially on the breast--"that I'm not in the secret service myself? Would you like to hear what is in these bills that you are
  • 35. going to help me stick on the walls? I've just come from the printing office where I've had them printed. You can't read, you say; it is a pity you should be left in the dark, so I'll read it to you." Dick spread one out, and read it aloud, with unction. "It reads well, doesn't it? I'm rather proud of it. That's a figure of Justice on the top. My idea. Rather a good idea, I flatter myself. A pretty fellow you are to come and threaten me with your rope and grapnel! I'll tell you what your game is, Mr. Higgins. Blackmail. That is it--blackmail. A dangerous game, old man, and you've got hold of the wrong end of the stick-- perhaps you see that now. If I had anything to fear is it likely that I'd be going about in open daylight sticking up these bills? More likely to be sailing on the open seas for some foreign port. Where are your wits, you clumsy idiot?" To judge from Mr. Higgins's appearance, they had gone wool- gathering. He literally gasped beneath the volley which Dick had poured upon him, at the end of which he was sitting in his chair in a state of helpless collapse. Dick had turned the tables upon him with a vengeance. "Now, what have you got to say?" he asked, triumphantly. "Quartern o' rum," gasped Mr. Higgins. "When we've finished our confab you shall have it, and another one or two on the top of it as we go along. Lord bless you, Mr. Higgins, I'm not an ill-natured chap, if you take me easy, and I have the credit of generally being freehanded when I'm not interfered with. Pull yourself together, and listen to what more I've got to say. What we want to do--the secret service, the detectives, the Criminal Investigation Department, and all of us--is to keep this matter as quiet as possible till the thieves and murderers are nabbed. We're working on the strict q.t., and we've got something up our sleeve, I can tell you. And I'll tell you something more. If any outsider interferes with our game by blabbing about ropes and grapnels it will be the worst day's work he
  • 36. has ever done, and he'll live to rue it. We'll wipe him out, that's what we'll do. We'll have no mercy on him." This was the finishing stroke. Mr. Higgins lay helpless at the foot of the conqueror. "I made a mistake," he whined. "Quartern o' rum." "You would sell your own mother for drink, I believe." "No, no," protested Mr. Higgins, feebly, "not so bad as that, not so bad as that. Good for my liver. Keeps me alive." "A nice state your liver must be in," said Dick, laughing. "I think we understand each other. Take up the paste pot, and carry it steady. You shall be paid for your day's work. Tenpence an hour, so look sharp." Mr. Higgins, completely subdued, had his fourth quartern at the bar, and shortly afterwards the British public had the privilege of seeing Dick Remington stick up the murder bills, assisted by an old man in skull cap and list slippers, in that stage of palsy from his recent experiences that his course was marked by a dribble of paste spilt from the pot he carried in his trembling hands. At every fresh stoppage a crowd gathered, arguing, disputing, airing theories. These chiefly consisted of conjectures as to who the murderer was, how the murder had been committed, how many were in it, who the man was who had been seen by Dr. Pye coming out of the house in Catchpole Square at three in the morning, whether he was the same man who had imposed upon Lady Wharton, how the blood-stained marks of footsteps on the floor were to be accounted for, whether there was any chance of the jewels being recovered, and so on, and so on. At one place there was a conversation of a different nature. "What I find fault with in that there bill," said an onlooker, a man with a forbidding face, dressed in corduroy, "is that no pardon is offered to any accomplice as didn't actually commit that there
  • 37. murder. Where's the indoocement to peach on a pal, that's what I want to know?" "A white-livered skunk I'd call him whatever his name might be," remarked a second speaker. "Honour among thieves, that's what I say." "Oh, come," said a third, "let's draw the line somewhere." "It's what they put in the bills," grumbled the man in corduroy, offering no comment on these expressions of opinion, "and I don't see no mention of it in that there blooming bill." "It's what they put in the Government bills," said the second man, "but this ain't a Government bill. It's a reward of £500 offered by a private individual." "A private individual!" sneered the first speaker. "You don't call Mr. Reginald Boyd a private individual in this here case, do you? He's a interested party, that's what he is. What I say is--and anybody can take it up as likes--where's the indoocement to peach on a pal?" "Well, don't take it to heart, mate," said another. At which there was a general laugh. "Do you know how it runs in the Government bills?" "No, I don't; but I know it's alias there, and allus should be there." "I can give you the words, if you wish to hear them," said a quiet onlooker, who, meditatively rubbing his chin, was watching the crowd and the billsticker. Dick repressed a start. It was the voice of Detective Lambert, with whom he was acquainted. He turned and accosted the officer, who put his finger to his lips, thus indicating that they were not to address each other by name.
  • 38. "Good morning," said Dick. "Good morning," said Lambert. "I did not know you were in this line of business." "Anything to turn an honest penny, said Dick, cheerfully. "Give us the words, mate," said the man in corduroy. "They run in this way. 'And the Secretary of State for the Home Department will advise the grant of her Majesty's gracious Pardon to any accomplice not being the person who actually committed the murder, who shall give such evidence as shall lead to a like result.'" "You seem to be well up in it, guv'nor." "Fairly well. I did a turn in a Government printing office once." "Then you could inform us, perhaps, as a matter of general interest," said an elderly man, "whether the accomplice, who would be Queen's evidence----" "Yes, Queen's evidence." "Would get the reward as well as the pardon?" "In course he would," said the man in corduroy, answering for Lambert. "That's the beauty of it. Only wish I was an accomplice in this here blooming murder, with them words in that there bill orfered by the Government. I'd touch, mates, pretty quick, that's what I'd do. But as it stands, where's the indoocement? It ain't 'arf a bill without the indoocement." This insistence of the implied merit attaching to an act of treachery did not seem to meet with the approval of many in the crowd, who edged away, with distrustful looks at the speaker. Dick
  • 39. also walked off, and Detective Lambert walked by his side awhile, Mr. Higgins shambling humbly in the rear. "A bold move," remarked Lambert. "A proper move," said Dick. "Anything new stirring?" Lambert rubbed his chin for two or three moments without replying, and few persons would have supposed that he was paying much visual attention to the man at his side or the man in the rear; but Dick knew better. He knew that detective Lambert was one of the shrewdest and the most observant officers in the service, and that nothing escaped his attention. "Five hundred pounds is a good round sum," he said. "It is," said Dick. "Why not earn it?" Lambert gave him a curious look, surprised, for one brief moment, out of himself. "If it was a Government reward," continued Dick, who also had his eyes about him, "there wouldn't be a chance for you, for the words would run, 'the above reward will be paid to any person (other than a person belonging to a police force in the United Kingdom) who shall give such information,' etc. Now, this reward doesn't apply in this way. The reward will be willingly and gladly paid to any person, whether he belongs to the police or not. Is it worth considering?" "Yes," said Lambert, thoughtfully, "it is worth considering. You asked me whether there's any thing new stirring. Well----" But he paused suddenly, as if he were about to say too much. "One of these days, perhaps, there will be a case in the papers that, for daring and mystery, will beat even the Mystery of Catchpole Square." "Can't imagine one," said Dick. "It wouldn't be fair to ask if there's any connection between the two cases." He paused; Lambert was silent; Dick turned the subject. "What do you think of my new apprentice? A modern species of Ganymede, carrying the pastepot
  • 40. instead of the wine cup. Nothing like novelty in these days; people run crazy after it. Only you must keep it well advertised; everything depends upon that. Drop your advertisements, and youth grows wrinkled in an hour. Now, what we're aiming at in this mystery"--he flourished his paste brush--"is that, until we get at its heart, people shan't forget it. We'll keep it before them morning, noon, and night. No hole-in-the-corner business. Step up, old man." This to Mr. Higgins, who came shambling forward, his features twitching twenty to the dozen. With the eyes of so sharp an officer as Lambert upon him Dick was not stupid enough to dream of keeping the old man in the background. He knew that any such attempt would end in Lambert's finding means of making himself thoroughly acquainted with Mr. Higgins's business and character before the day was out, so he took the bull by the horns, and introduced his companion by name, giving also his trade and address. "There's a specimen of an honest tradesman for you. Queer sort of assistant for me to pick up?" "There's no denying it," said Lambert. "There's a little story attached to the way Mr. Higgins and I struck up a friendship. What's the best thing in life worth living for, old man?" "Quartern o' rum," replied Mr. Higgins. The answer seemed to be jerked out of him by force of magnetism. Dick laughed; Lambert made a movement of departure. "Are you off?" asked Dick. "Off I am. Take care of yourself." "I'll try to." Dr. Pye's countenance during his late interview with Dr. Vinsen was not more inscrutable than that of Detective Lambert. The
  • 41. trained habit of concealing one's thoughts is part of the stock in trade of more than one class of men, and shrewd as Dick was he would have found it beyond his power to divine what was passing in Lambert's mind as he strolled leisurely away, but a quiet smile on the younger man's lips denoted that he was not dissatisfied with the problem he had presented to the detective. "I've given him something to puzzle over," was Dick's thought, "and I'm a Dutchman if I haven't thrown him off the scent in regard to my friend Higgins." "There's a man for you," he said, as he gazed admiringly after the vanishing figure of the detective. "Have you the pleasure of knowing the gentleman?" "Can't say as I have," was the answer. "That's the famous Detective Lambert, who gave evidence at the inquest. And what a ferret he is! Search France and England through, and you won't meet his match. He had his eye on you, I noticed." Mr. Higgins shivered. "If ever you get into his clutches look out for snakes. It's a pleasure to work with a man like that. He and I are on the same lay." Another hour's steady work, and the last bill was pasted on the walls and the last quartern of rum disposed of. Then he reckoned up what was due to Mr. Higgins, paid and dismissed him, and repeated his caution about looking out for snakes if it should be his bad fortune to fall into the clutches of the famous detective. "I've about settled your hash," mused Dick, as he saw Mr. Higgins plunge into the nearest beershop. "But how do I stand with Lambert? That's a different pair of shoes. What did he mean about another case of mystery? I thought he was going to let it out, but he pulled himself up short. Never mind, Dick. You've had a narrow squeak to-day, and you've got out of it with flying colours. Go ahead, my lad, and stick at nothing."
  • 42. Had Detective Lambert followed Dick to the neighbourhood of Covent Garden and overheard what passed between him and certain well known tradesmen therein he would have had another problem to solve, in addition to those which were already occupying his attention. CHAPTER XLVI. "THE LITTLE BUSY BEE'S" REPORT OF THE CONTINUATION OF THE INQUEST. The inquiry into the death of Mr. Samuel Boyd was resumed at the Coroner's Court in Bishop Street this morning before Mr. John Kent. Long before eleven o'clock the usual crowd of persons had gathered round the doors, but so numerous had been the application for seats from privileged and influential quarters that very few of the general public succeeded in gaining admittance. Intense as has been the interest evinced in this extraordinary case, the startling and unexpected revelations made by witnesses who have voluntarily come forward to give evidence have raised it to a level reached by no other murder mystery in our remembrance. It would be idle to deny that the evidence of the last witness examined yesterday has given a significant turn to the proceedings. So far as we have been able to ascertain, the police have obtained no clue to the man who personated Samuel Boyd and who so successfully imposed upon Lady Wharton in Bournemouth. We understand that it is the intention of her ladyship's advisers to offer
  • 43. a substantial reward for the recovery of her jewels, and a list of them, with detailed descriptions, has been sent to every pawnbroker in the kingdom. To this course we ourselves see no objection, although we are aware that many of the Scotland Yard officials are strongly of the opinion that the offer of a reward in such cases only serves to put the guilty parties more carefully on their guard. For the same reason they may object to the bills that are now being posted in London offering rewards for the discovery and conviction of the murderer or murderers, and for the discovery of Abel Death, of whom no news whatever is as yet forthcoming. The bills are appropriately headed "In the Cause of Justice," and it is to be hoped that they will assist the cause of justice. We make no comment upon the circumstance that Mr. Reginald Boyd, at whose instance this step has been taken, has made himself responsible for the payment of £500 in the one case and £200 in the other. The argument that it will stimulate persons to recall apparently insignificant details in connection with the movements of the guilty parties, and to make them public, is sound, for important results have been known to spring from the revelation of details which in ordinary circumstances would be considered too trivial to mention. In the course of the next few days further developments may be expected. It was understood that this morning's proceedings would be opened with the examination of Mrs. Abel Death, but before she was called Mr. Reginald Boyd rose and addressed the Coroner. Mr. Reginald Boyd: "I ask permission to say a few words." The Coroner: "You have already been examined, Mr. Boyd, and I am desirous not to subject the jury to the inconvenience arising from an inquiry unduly protracted." Mr. Reginald Boyd: "I can assure you, Mr. Coroner, and you, gentlemen of the jury, that I do not wish to waste your time, but you must see that what has transpired in the course of this inquiry affects me most deeply. In common justice I ask to be heard."
  • 44. The Juror: "Let us hear what Mr. Reginald Boyd has to say." The Coroner: "I am in your hands, gentlemen." Mr. Reginald Boyd: "After the evidence given by Dr. Pye--or rather I should say, after the statement he has made affecting myself--my desire is to declare even more positively than I did yesterday that I reached my lodgings on Friday night within a few minutes of midnight, that I went to bed, and did not arise from it for a week in consequence of my illness. I fear that it is not in my power to offer corroborative evidence. My landlady and her servant went to bed, I understand, between ten and eleven o'clock, and have no recollection of hearing anybody come into the house after they retired. It is my misfortune, also, that I was the only lodger in the house. I let myself in with my latchkey. I have no remembrance of meeting with anyone nor of speaking to anyone, but I can swear to the time because I looked at my watch, and wound it up in my bedroom." The Coroner: "Very well. Perhaps you had better not say anything more." Mr. Reginald Boyd: "Why not, Mr. Coroner? I desire it to be widely known that I court the fullest and most searching inquiry. I cannot avoid seeing that Dr. Pye's statement that the man he saw bore a striking resemblance to myself throws a grave suspicion upon me. I do not impugn his evidence, but I contend that it is only fair that equal consideration should be given to my statement as to his. I will endeavour to make myself clearer. I affirm upon my oath that I was in my bed within a few minutes of midnight, and did not leave it again. Dr. Pye affirms that three hours afterwards he saw a person resembling me leave my father's house in a suspicious manner. To the truth of my statement I can bring forward no witnesses. Can Dr. Pye bring forward any witnesses to the truth of his? If uncorroborated evidence given by me is open to doubt, so should uncorroborated evidence given by him be viewed. A man's honour--
  • 45. to say nothing of a son's innocence or guilt of so awful a crime as the murder of his father--is not to be judged by a stranger's unsupported word. In the sacred name of justice I protest against it." These words, spoken with manliness and deep emotion, made a marked impression upon the audience, which was deepened when they turned to the glowing face of the witness's wife. A murmur of sympathy ran through the Court. The Juror (referring to his notes): "But in your account of the incidents of that night you informed us that you could not depend upon your memory. Quoting your own words: 'I was deeply agitated, and my mind was in confusion. The fever from which I immediately afterwards suffered, and which kept me to my bed several days, may have been upon me then.' Do you adhere to that?" Mr. Reginald Boyd: "I do. In describing my condition my endeavour was to speak the honest truth, and to offer no excuse which could not be accepted by an impartial mind, nor to take advantage of any. But that does not affect my distinct recollection as to the time I wound up my watch in my bedroom." The Juror: "We must not, however, lose sight of the fact that no suspicion attaches to Dr. Pye, and that it is not his veracity that is here in question." Mr. Reginald Boyd (with warmth): "Is that a fair remark from one of the jury?" The Coroner: "It is a most improper remark, and should not have been made in open Court. Call Mrs. Abel Death."
  • 46. CHAPTER XLVII. "THE LITTLE BUSY BEE" CONTINUES ITS REPORT OF THE INQUEST. The public are by this time acquainted with much of the evidence Mrs. Death had to offer. After narrating the circumstances of her husband's dismissal from the service of Mr. Samuel Boyd, and of his going late at night to Mr. Boyd's house in Catchpole Square to beg to be taken back, the examination proceeded as follows: "What salary did your husband receive from Mr. Boyd?" "Twenty-two shillings a-week, with deductions for imaginary faults." "Did he work long hours?" "From nine in the morning till eight at night. Occasionally he worked overtime, but was never paid anything extra." "He was not happy in his situation?" "How could he be, sir, with such a master?" "They had frequent disagreements?" "I'm sorry to say they had; but it wasn't my husband's fault." "Did he ask Mr. Boyd for a loan of ten pounds?" "Yes, sir." "He hoped it would be granted?"
  • 47. "We fully expected it, sir." "The refusal to grant the loan must have been a great disappointment to your husband?" "It almost broke his heart, sir." "May that not have exasperated him, and caused him to speak words to Mr. Boyd which might have been construed into a threat?" "I am sure that could not have happened. My husband was most particular in telling me everything that passed between them, and he didn't use a threatening word. He did ask Mr. Boyd if he believed in God, and Mr. Boyd said no, he didn't." "Then there was bad blood between them when they parted?" "I suppose there was, sir." "To what do you attribute Mr. Boyd's unexpected refusal to lend the money?" "To Mr. Reginald's visit in the afternoon. It made his father furious." "Now, as to the object of Mr. Reginald Boyd's visit in the afternoon. Was it to obtain money from his father?" "That was what my husband believed." "And was this the object of his second visit late at night?" "My husband said of course it must be that, but that he wouldn't get a penny out of the old man." "After your husband's dismissal, are you aware whether he and Mr. Reginald Boyd met?"
  • 48. "They couldn't have met, sir, or my husband would have told me." "No doubt you have heard many of the theories that have been advanced to account for his absence from his home?" "Well, sir, I have. Some say--the wretches!--that he murdered Mr. Boyd, and has run off with the money. Some say that he has made away with himself, but it isn't possible he could have thought of such a thing. I was a bit afraid of it the last night I saw him when he started up to go to Catchpole Square, but he saw what was in my mind, and he said, 'Don't you think that of me. You've got trouble enough to bear; I'm not going to bring more upon you. I'll do my duty, and fight on to the bitter end.' And that's what he would have done." "Have you any idea at all as to the cause of his absence?" "Yes, sir. Foul play." "Did he have any enemies?" "Not to my knowledge, sir. He wasn't of a quarrelsome disposition." "Were there any money transactions between him and Mr. Reginald Boyd?" "Not exactly transactions, sir. Once, when we had sickness at home, Mr. Reginald saw that my husband was worried, and he asked him if he was in any trouble. Hearing what it was, and that we were frightened to send for a doctor because of the expense, he gave my husband two sovereigns. We thought it was a loan, but afterwards, when we offered to pay it off at a shilling a week, Mr. Reginald said it was only a friendly little present, and that he would be vexed if we didn't look upon it as such. I remember my husband saying, 'I wish I was working for Mr. Reginald instead of for his father.' We were very
  • 49. grateful to him, and I always looked upon him as a model young gentleman till old Mr. Boyd was murdered, and then----" "Why do you pause? Go on." "No, sir, I won't. It wouldn't be fair." The Juror: "But we should like to hear, Mrs. Death?" "I'm not going to say anything more about it, sir, unless you force me to it. Every man ought to have his chance." The Juror (to the Coroner): "I think, Mr. Coroner, the witness should be directed to finish the sentence." The Coroner (to Mrs. Death): "You would rather not say what is in your mind?" Mrs. Death: "I would rather not, sir." "Then I shall not ask you to disclose it." The Juror: "But, Mr. Coroner----" The Coroner: "I am conducting this inquiry, and I have given my decision." (To the witness). "How long did you remain up on Friday night after your husband went to make a last appeal to his employer?" "I did not go to bed at all that night. I waited for him till nearly two in the morning, and then I went to Catchpole Square, on the chance that Mr. Samuel Boyd would be able to give me some information of him. I knocked at the door, and hung about the Square a goodish bit, but I couldn't get anyone to answer me. Then I came home again, and waited and waited." "You went from your house at two in the morning?"
  • 50. "About that time, sir." "How long did it take you to reach Catchpole Square?" "It was a dark night, and I should think it took me half an hour or so." "So that you would be in front of Mr. Boyd's house at about half past two?" "Yes, sir." "You knocked more than once?" "Several times, sir." "And waited between each fresh summons for an answer?" "For the answer that never came, sir." "And after that, you hung about the Square. Can you say for how long a time?" "I can't speak with certainty, but I should say I must have been there altogether quite an hour." "That brings us to half past three?" "Yes, sir." The Juror: "I see your point, Mr. Coroner, but the witness did not probably possess a watch." The Coroner: "Have you a watch or a clock in your rooms?" "No, sir." "Then your statement as to the time is mere guesswork?"
  • 51. "No, sir. When I was in Catchpole Square I heard a church clock strike three." The Coroner (to a constable): "Do you know if there is an officer in Court who lives near Catchpole Square?" The Constable: "I do myself, sir." The Coroner: "Is there a church close by that tolls the hour?" The Constable: "Yes, sir, Saint Michael's Church." The Coroner: "It can be heard in Catchpole Square?" The Constable: "Quite plainly, sir." The Coroner: "Thank you." (To Mrs. Death). "You heard the hour strike when you had been some time in the Square?" "I must have been there half an hour." "And you remained some time afterwards?" "For as long again." "Are you certain that the church clock struck three?" "I am, sir. I counted the strokes." "You did not move out of the Square?" "No, sir." "During the whole time you were there was the door of Mr. Samuel Boyd's house opened?" "No, sir."
  • 52. "You did not see any man come from the house, and linger on the threshold of the door?" "No, sir." "At about that hour of three did you observe a sudden flash of light from an opposite house?" "No, sir, it was quite dark all the time I was there." "You are quite positive?" "Quite positive, sir." While these questions were asked and answered the spectators in Court, many of whom had been present while Dr. Pye was giving his evidence yesterday, held their breath, as it were, and an expression of intense relief was observable in the countenances of Mr. Reginald Boyd and his wife and her parents. The Juror: "Do you think, Mr. Coroner, that the evidence on the point of time is reliable?" The Coroner: "As reliable as the evidence of witnesses on other points." The Juror: "It is uncorroborated." The Coroner: "So is the evidence of Dr. Pye, as Mr. Reginald Boyd remarked." The Juror: "So is Mr. Reginald Boyd's evidence." The Coroner: "Exactly." (To Mrs. Death.) "I have no further questions to ask you."
  • 53. CHAPTER XLVIII. THE CORONER'S SUMMING-UP. "We have now," said the Coroner, addressing the jury, "arrived at the end of the inquiry, so far as the examination of witnesses is concerned, and the duty devolves upon you of carefully considering the evidence, and of giving your verdict. At the opening of this inquiry I made a strong appeal to you to keep an open mind, and not to be influenced by the rumours and theories which have been freely broached by press and public. It is in this way that the interests of justice will be best served. The case is one of the gravest import, and your task one of unusual difficulty. For this reason I feel it my duty to address you at greater length than is usual in inquiries of this nature. "There are leading points in the case which we may take as established beyond dispute. One is that a murder has been committed, a murder of extreme brutality, and distinguished by features of extreme cunning. Another, that the man murdered is Mr. Samuel Boyd. Another, that the murder was committed on the night of the 1st or the 2nd of March. "That the crime should have remained undiscovered so long is due to the peculiar domestic habits of the deceased, and to the facts that he kept no servants in his house, that he lived quite alone, and that on the evening of the 1st of March he dismissed the only person whom he kept regularly employed. Had this dismissal not been given, and had Mr. Abel Death, his clerk, gone to his work as usual on the following morning, the discovery of the murder would have
  • 54. been made within a few hours of its perpetration, and the task before you would have been rendered far less difficult. I would not have you attach too much importance to the apparent connection between the perpetration of the murder and the disappearance of Mr. Abel Death. Coincidences as strange are not uncommon in matters less serious, and it is not because this matter is serious that the coincidence should be construed to the disadvantage of a man who is absent. Up to Friday, the 1st of March, his relations with his employer were as fairly satisfactory as could have been expected from the miserable stipend he received and from the character of the murdered man, and, unpleasant as those relations became on that last day, there was nothing in them, so far as we are aware, to supply a reason for the committal of a deliberate and dastardly murder, all the details of which must have been carefully planned. If Mr. Abel Death had been a party to this plan he would hardly have asked his employer for a loan of ten pounds, a small sum for a rich man to grant to his confidential clerk. "For the purpose of arriving, as far as possible, at a clear comprehension of this part of the mystery let us for a moment follow the probable movements of Mr. Death on that night. "He is dismissed from his employment, and he leaves the office, a disappointed and unhappy man; he relates to his wife all that passed between him and his employer, and subsequently informs her that he is going to Catchpole Square to make another appeal to his employer. I gather that the time of his arrival at the house would be about ten o'clock, at which hour we may assume that Mr. Samuel Boyd had not retired to rest. At about nine o'clock Lady Wharton left Mr. Samuel Boyd at the door of his house, and from that moment all is mystery. We know, however, that he must have had matters to attend to which would keep him up a couple of hours. Lady Wharton had deposited with him a number of valuable jewels, to which, when she was gone, he would naturally devote attention, appraising them, and probably taking a list of them. The dismissal of his clerk would most likely cause him to pay some attention to the state of the
  • 55. books and accounts, and the jewels had to be put in a place of safety. "All this would occupy him a couple of hours, and this brings us to eleven o'clock, when he would be ready to seek his bed. But before this hour Mr. Abel Death, according to the theory we are following out, has paid his visit, or rather, has made his attempt to see his employer. He knocks at the door, and in response to the summons Mr. Boyd goes down to see who is there. A man living alone in a house so safely removed from public observation would be scarcely likely to open his street door to casual visitors at ten o'clock at night, nor, the business of the day being over, would he neglect to put the chain on the street door. His probable course of action would be to go down, and, opening the door as far as the chain would allow, inquire who is there. He is answered by Mr. Death, who begs to be admitted to make his appeal; is refused; while standing in the square implores to be taken back; is listened to, laughed at, ordered to go away, and the door shut in his face. "I do not see how we can carry the matter farther as regards Mr. Death. To assume that he is admitted to the house, and that Mr. Boyd went to bed in his presence, is so wildly improbable that we may at once reject it. If anything can be said to be ridiculous in so awful a tragedy it would be to suppose that Mr. Boyd thus placed himself in the power and at the mercy of a man whom he knew to be embittered against him, and who was in a sense desperate. As to Mr. Abel Death's subsequent movements we are left in mystery. His wife suggests foul play. That a man left in the position to which my argument has carried him should deliberately conceal himself without a distinct motive is not to be thought of, and for this reason I consider the suggestion of foul play tenable. From whom, or from what quarter, who shall say? But we are not here to inquire into this matter; it is not the fate of Mr. Death we have to deliberate upon, and I advise you therefore to narrow the issue, which is sufficiently wide and perplexing, by setting him aside. There is nothing whatever to connect him with the crime beyond the merest
  • 56. conjectures, and were he alone concerned the only verdict that could be returned would be one of 'Murder by some person or persons unknown.' "We will now turn to another branch of the subject. In reply to a question I put to Mrs. Death she expressed her belief that her husband had no enemies: but a man carrying on such a business as Mr. Samuel Boyd transacted must have had many. However harsh it may sound, there is in my mind very little doubt that he must have inflicted great wrongs upon a number of persons. The tactics pursued by moneylenders of his class are so tricky and unscrupulous--they are so entirely oblivious of the claims of common humanity--that they must perforce breed animosity and resentment in the breasts of those whom they entrap. I am referring, understand, to that class of moneylenders whose nefarious practices have made them a danger to society, and I am happy to see that the strong arm of the law is being stretched forward to protect the unwary and unsuspecting victims who fall into their clutches. On the other hand, there are, of course, among such a man's customers some crafty borrowers who would trick the moneylender as he would trick them, men with doubtful reputations whose characters are no better than his own. It is for your consideration whether Mr. Samuel Boyd has fallen a victim to a cunningly laid plot on the part of a band of these men; the abstraction of the books and papers in which their names would appear favours this presumption. We have no evidence presented to us that affords a clue to the discovery of such a plot, but it will be as well not to lose sight of its probable existence. "Returning to my argument concerning Mr. Samuel Boyd's movements within his house on the night in question, we behold him still alone at about eleven o'clock, his office business finished, the visit of Mr. Abel Death disposed of, and he preparing for bed. And here Mr. Reginald Boyd comes into the picture.
  • 57. "We have heard from his lips his account of what took place during his interview with his father, and we have to accept or reject it. They were alone together, there were no witnesses, and we have only Mr. Reginald Boyd's word to go upon. You must not allow this to militate against him. In the circumstances of the case it is hardly possible that there could have been witnesses to corroborate the account he gave, and I have no hesitation in declaring that his bearing in the witness box bore the impress of truth. It has been objected to that in the course of this inquiry private domestic affairs have been dragged into the light which seemingly had no connection with it, but painful as this must have been to certain of the witnesses, it has established more than one point which, in the opinion of some of you, may be of importance--such, for instance, as the nature of the relations which existed between Mr. Samuel Boyd and his son, and the fact that the latter was in extremely straitened circumstances. I do not think that any blame is to be attached to the son for having renounced the name of Boyd two years ago, when the strained relations between him and his father led to his leaving, or being turned from, his home in Catchpole Square. It is not an instance without parallel; men have changed their names for motives less powerful than this. Mr. Reginald Boyd's bearing while giving his evidence here, was that of a high-spirited, independent young gentleman, who held in abhorrence the business tactics and practices of his father, and it is not unnatural, when the connection was severed, that he should resolve to be quit of a name which carried with it a disreputable stigma. "Nor was it unnatural that Mr. Reginald Boyd should have believed himself to have been tricked out of the fortune his mother left him, and that, being now a married man, anxious to provide a home for his wife, he should have made an effort to obtain restitution. In my reference to these matters I am not wandering from the issue, for what you have to consider is, not one incident, circumstance, or act, apart from the others, but all the incidents, circumstances, and acts in relation to each other. What in the former case may seem
  • 58. 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! ebookname.com