0% found this document useful (0 votes)
17 views

Ruby for Rails Ruby techniques for Rails developers David Black instant download

The document provides information about various Ruby and Rails programming resources, including books and tutorials by different authors. It highlights titles such as 'Ruby for Rails' by David Black and 'Ruby on Rails Tutorial' by Michael Hartl, along with links for instant ebook downloads. Additionally, it includes details about the structure and contents of the 'Ruby for Rails' book, covering Ruby fundamentals and Rails development techniques.

Uploaded by

mchinamamuki49
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Ruby for Rails Ruby techniques for Rails developers David Black instant download

The document provides information about various Ruby and Rails programming resources, including books and tutorials by different authors. It highlights titles such as 'Ruby for Rails' by David Black and 'Ruby on Rails Tutorial' by Michael Hartl, along with links for instant ebook downloads. Additionally, it includes details about the structure and contents of the 'Ruby for Rails' book, covering Ruby fundamentals and Rails development techniques.

Uploaded by

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

Ruby for Rails Ruby techniques for Rails

developers David Black pdf download

https://ebookname.com/product/ruby-for-rails-ruby-techniques-for-
rails-developers-david-black/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Ruby on Rails Tutorial Learn Web Development with Rails


2nd Edition Michael Hartl

https://ebookname.com/product/ruby-on-rails-tutorial-learn-web-
development-with-rails-2nd-edition-michael-hartl/

Beginning Ruby on Rails 1st Edition Steve Holzner

https://ebookname.com/product/beginning-ruby-on-rails-1st-
edition-steve-holzner/

Ruby on Rails Up and Running 1st Edition Bruce Tate

https://ebookname.com/product/ruby-on-rails-up-and-running-1st-
edition-bruce-tate/

Down by the Bay San Francisco s History between the


Tides 2013 Matthew Booker

https://ebookname.com/product/down-by-the-bay-san-francisco-s-
history-between-the-tides-2013-matthew-booker/
The Gluten Proteins Special Publication 1st Edition D.
Lafiandra

https://ebookname.com/product/the-gluten-proteins-special-
publication-1st-edition-d-lafiandra/

Fluid Mechanics and Thermodynamics of Turbomachinery


6ed Edition Dixon S.L.

https://ebookname.com/product/fluid-mechanics-and-thermodynamics-
of-turbomachinery-6ed-edition-dixon-s-l/

Digital Signal Processing Using MATLAB for Students and


Researchers 1st Edition John W. Leis

https://ebookname.com/product/digital-signal-processing-using-
matlab-for-students-and-researchers-1st-edition-john-w-leis/

Buffer States in World Politics John Chay (Editor)

https://ebookname.com/product/buffer-states-in-world-politics-
john-chay-editor/

Nonverbal behavior in clinical settings 1st Edition


Feldman

https://ebookname.com/product/nonverbal-behavior-in-clinical-
settings-1st-edition-feldman/
The Adventures of Huckleberry Finn Webster s Chinese
Traditional Thesaurus Edition Mark Twain

https://ebookname.com/product/the-adventures-of-huckleberry-finn-
webster-s-chinese-traditional-thesaurus-edition-mark-twain/
Ruby for Rails
Ruby for Rails
RUBY TECHNIQUES FOR RAILS DEVELOPERS

DAVID A. BLACK

MANNING
Greenwich
(74° w. long.)
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in
quantity. For more information, please contact:
Special Sales Department
Manning Publications Co.
209 Bruce Park Avenue Fax:(203) 661-9018
Greenwich, CT 06830 email: manning@manning.com
©2006 Manning Publications. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted,


in any form or by means electronic, mechanical, photocopying, or otherwise, without
prior written permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial
caps or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books they publish printed on acid-free paper, and we exert our best efforts to that end.

Manning Publications Co. Copyeditor: Liz Welch


209 Bruce Park Avenue Typesetter: Gordan Salinovic
Greenwich, CT 06830 Cover designer: Leslie Haimes

ISBN 1932394699
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – VHG – 10 09 08 07 06
for n in nephews + nieces

which is to say: Annie, David, Elizabeth, Rebecca, and Robert,


with all my love. You’re all absolutely amazing, and I adore you.
brief contents
PART I THE RUBY/RAILS LANDSCAPE ...........................1
1 ■ How Ruby works 3
2 ■ How Rails works 33
3 ■ Ruby-informed Rails development 67

PART II RUBY BUILDING BLOCKS ................................93


4 ■ Objects and variables 95
5 ■ Organizing objects with classes 121
6 ■ Modules and program organization 154
7 ■ The default object (self) and scope 177
8 ■ Control flow techniques 206

PART III BUILT-IN CLASSES AND MODULES ...............231


9 ■ Built-in essentials 233
10 ■ Scalar objects 257
11 ■ Collections, containers, and enumerability 277

vii
viii BRIEF CONTENTS

12 ■ Regular expressionsand regexp-based string operations 312


13 ■ Ruby dynamics 337

PART IV RAILS THROUGH RUBY,


RRRRRRRRIRUBY THROUGH RAILS ............................. 369

14 ■ (Re)modeling the R4RMusic application universe 371


15 ■ Programmatically enhancing ActiveRecord models 392
16 ■ Enhancing the controllers and views 422
17 ■ Techniques for exploring the Rails source code 455

appendix ■ Ruby and Rails installation and resources 471


contents
foreword xix
preface xxi
acknowledgments xxiii
about this book xxvi
about the cover illustration xxxii

PART 1 THE RUBY/RAILS LANDSCAPE ...........................1

1 How Ruby works 3


1.1 The mechanics of writing a Ruby program 4
Getting the preliminaries in place 5 A Ruby literacy bootstrap

guide 5 A brief introduction to method calls and Ruby objects 7


Writing and saving a sample program 8 Feeding the program to


Ruby 9 Keyboard and file input 11 One program,


■ ■

multiple files 14
1.2 Techniques of interpreter invocation 15
Command-line switches 16 A closer look at

interactive Ruby interpretation with irb 20


1.3 Ruby extensions and programming libraries 21
Using standard extensions and libraries 21 Using

C extensions 22 Writing extensions and libraries 23


ix
x CONTENTS

1.4 Anatomy of the Ruby programming environment 24


The layout of the Ruby source code 24 Navigating the

Ruby installation 25 Important standard Ruby tools


and applications 27
1.5 Summary 31

2 How Rails works 33


2.1 Inside the Rails framework 34
A framework user’s–eye view of application development 35
Introducing the MVC framework concept 36
Meet MVC in the (virtual) flesh 37
2.2 Analyzing Rails’ implementation of MVC 38
2.3 A Rails application walk-through 41
Introducing R4RMusic, the music-store application 42
Modeling the first iteration of the music-store domain 43
Identifying and programming the actions 50 Designing

the views 53 Connecting to the application 58


2.4 Tracing the lifecycle of a Rails run 59


Stage 1: server to dispatcher 61 Stage 2: dispatcher

to controller 62 Stage 3: performance of a controller


action 62 ■ Stage 4: the fulfillment of the view 65


2.5 Summary 65

3 Ruby-informed Rails development 67


3.1 A first crack at knowing what your code does
Seeing Rails as a domain-specific language 70 Writing program

69

code with a configuration flavor 73 YAML and configuration


that’s actually programming 75


3.2 Starting to use Ruby to do more in your code 77
Adding functionality to a controller 79 Deploying the Rails helper

files 80 Adding functionality to models 82


3.3 Accomplishing application-related skills and tasks 85


Converting legacy data to ActiveRecord 85
The irb-based Rails application console 89
3.4 Summary 90
CONTENTS xi

PART 2 RUBY BUILDING BLOCKS .................................93

4 Objects and variables 95


4.1 From “things” to objects 96
Introducing object-oriented programming 97 I, object! 98 ■

Modeling objects more closely: the behavior of a ticket 103


4.2 The innate behaviors of an object 108
Identifying objects uniquely with the object_id method 109
Querying an object’s abilities with the respond_to? method 110
Sending messages to objects with the send method 111
4.3 Required, optional, and default-valued arguments 112
Required and optional arguments 112 Default values for ■

arguments 113 Order of arguments 114


4.4 Local variables and variable assignment 115


Variable assignment in depth 117 Local variables ■

and the things that look like them 119


4.5 Summary 120

5 Organizing objects with classes 121


5.1 Classes and instances
A first class 123 ■
122
Instance variables and object state 126
5.2 Setter methods 130
The equal sign (=) in method names 131
ActiveRecord properties and other =-method applications 133
5.3 Attributes and the attr_* method family 136
Automating the creation of attribute handlers 137 Two (getter/ ■

setter) for one 138 Summary of attr_* methods 139


5.4 Class methods and the Class class 140


Classes are objects too! 140 When, and why, to write a class

method 141 Class methods vs. instance methods, clarified 143


The Class class and Class.new 144


5.5 Constants up close 145
Basic usage of constants 145 ■ Reassigning vs.
modifying constants 146
xii CONTENTS

5.6 Inheritance 148


Inheritance and Rails engineering 149 ■ Nature vs.
nurture in Ruby objects 151
5.7 Summary 153

6 Modules and program organization 154


6.1 Basics of module creation and use
A module encapsulating “stack-like-ness” 157 Mixing a module
155

into a class 158 Leveraging the module further 160


6.2 Modules, classes, and method lookup 163


Illustrating the basics of method lookup 163 Defining the same ■

method more than once 166 Going up the method search path

with super 168


6.3 Class/module design and naming 170
Mix-ins and/or inheritance 171 ■ Modular organization
in Rails source and boilerplate code 173
6.4 Summary 176

7 The default object (self) and scope 177


7.1 Understanding self, the current/default object
Who gets to be self, and where 179 Self as default receiver of

179

messages 184 Instance variables and self 186


7.2 Determining scope 188


Global scope and global variables 188 ■ Local scope 191
Scope and resolution of constants 194
7.3 Deploying method access rules 197
Private methods 197 ■ Private methods as ActionController
access protection 199 ■ Protected methods 201
7.4 Writing and using top-level methods 203
Defining a top-level method 203 ■ Predefined (built-in)
top-level methods 204
7.5 Summary 205

8 Control flow techniques 206


8.1 Conditional code execution
The if keyword and friends 208
207
■ Conditional modifiers 211
Case statements 211
CONTENTS xiii

8.2 Repeating actions with loops 215


Unconditional looping with the loop method 215
Conditional looping with the while and until keywords 216
Looping based on a list of values 218
8.3 Code blocks, iterators, and the yield keyword 219
The basics of yielding to a block 219 Performing multiple

iterations 222 Using different code blocks 223


More about for 223


8.4 Error handling and exceptions 225
Raising and rescuing exceptions 225 Raising exceptions

explicitly 227 Creating your own exception classes 228


8.5 Summary 230

PART 3 BUILT-IN CLASSES AND MODULES ...................231

9 Built-in essentials 233


9.1 Ruby’s literal constructors 234
9.2 Recurrent syntactic sugar 236
Special treatment of += 237
9.3 Methods that change their receivers (or don’t) 238
Receiver-changing basics 239 bang (!) methods 240

Specialized and extended receiver-changing in


ActiveRecord objects 241
9.4 Built-in and custom to_* (conversion) methods 242
Writing your own to_* methods 243
9.5 Iterators reiterated 244
9.6 Boolean states, Boolean objects, and nil 245
True and false as states 246 ■ true and false as objects 248
The special object nil 249
9.7 Comparing two objects 251
Equality tests 251 ■ Comparisons and the Comparable module 252
9.8 Listing an object’s methods 253
Generating filtered and selective method lists 254
9.9 Summary 255
xiv CONTENTS

10 Scalar objects 257


10.1 Working with strings

258
String basics 258 String operations 260
Comparing strings 265
10.2 Symbols and their uses 267
Key differences between symbols and strings 267
Rails-style method arguments, revisited 268
10.3 Numerical objects 270
Numerical classes 270 ■ Performing arithmetic operations 271
10.4 Times and dates 272
10.5 Summary 275

11 Collections, containers, and enumerability 277


11.1 Arrays and hashes compared 278
11.2 Using arrays 279
Creating a new array 279 Inserting, retrieving, and removing array

elements 280 Combining arrays with other arrays 283 Array


■ ■

transformations 285 Array iteration, filtering, and querying 286


Ruby lessons from ActiveRecord collections 289


11.3 Hashes 292
Creating a new hash 293 Inserting, retrieving, and removing hash

pairs 294 Combining hashes with other hashes 296 Hash


■ ■

transformations 297 Hash iteration, filtering, and querying 298


Hashes in Ruby and Rails method calls 301


11.4 Collections central: the Enumerable module 303
Gaining enumerability through each 304
Strings as Enumerables 306
11.5 Sorting collections 307
Sorting and the Comparable module 309
Defining sort order in a block 310
11.6 Summary 311

12 Regular expressionsand regexp-basedstring operations 312


12.1 What are regular expressions?
A word to the regex-wise 314 ■
313
A further word to everyone 314
CONTENTS xv

12.2 Writing regular expressions 314


The regular expression literal constructor 315
Building a pattern 316
12.3 More on matching and MatchData 319
Capturing submatches with parentheses 319
Match success and failure 321
12.4 Further regular expression techniques 323
Quantifiers and greediness 323 Anchors and lookahead

assertions 326 Modifiers 328 Converting strings and


■ ■

regular expressions to each other 329


12.5 Common methods that use regular expressions 331
String#scan 332 String#split 332
■ ■ sub/sub! and
gsub/gsub! 333 grep 334

12.6 Summary 335

13 Ruby dynamics 337


13.1 The position and role of singleton classes 338
Where the singleton methods live 339 Examining and modifying a

singleton class directly 340 Singleton classes on the method lookup


path 342 Class methods in (even more) depth 345


13.2 The eval family of methods 347


eval 347 instance_eval 349 The most useful
■ ■

eval: class_eval (a.k.a. module_eval) 349


13.3 Callable objects 351
Proc objects 351 Creating anonymous functions with the

lambda keyword 355 Code blocks, revisited 356 Methods


■ ■

as objects 357
13.4 Callbacks and hooks 359
Intercepting unrecognized messages with method_missing 360
Trapping include operations with Module#included 361
Intercepting inheritance with Class#inherited 363
Module#const_missing 365
13.5 Overriding and adding to core functionality 365
A cautionary tale 366
13.6 Summary 367
xvi CONTENTS

PART 4 RAILS THROUGH RUBY,


UUUUUUURUBY THROUGH RAILS ..................................369

14 (Re)modeling the R4RMusic application universe 371


14.1 Tracking the capabilities of an
ActiveRecord model instance 372
An overview of model instance capabilities 373
Inherited and automatic ActiveRecord model behaviors 374
Semi-automatic behaviors via associations 378
14.2 Advancing the domain model 380
Abstracting and adding models (publisher and edition) 380
The instruments model and many-to-many relations 382
Modeling for use: customer and order 386
14.3 Summary 390

15 Programmatically enhancing ActiveRecord models 392


15.1 Soft vs. hard model enhancement 393
An example of model-enhancement contrast 394
15.2 Soft programmatic extension of models 396
Honing the Work model through soft enhancements 398 Modeling

the customer’s business 399 Fleshing out the Composer 401


Ruby vs. SQL in the development of soft enhancements 401


15.3 Hard programmatic enhancement of model
functionality 404
Prettification of string properties 404 Calculating a work’s

period 409 The remaining business of the Customer 414


15.4 Extending model functionality with class methods 419


Soft and hard class methods 419
15.5 Summary 421

16 Enhancing the controllers and views 422


16.1 Defining helper methods for view templates
Organizing and accessing custom helper methods 425
424

The custom helper methods for R4RMusic 427


CONTENTS xvii

16.2 Coding and deploying partial view templates 429


Anatomy of a master template 429 ■ Using partials
in the welcome view template 430
16.3 Updating the main controller 436
The new face of the welcome action 436
16.4 Incorporating customer signup and login 438
The login and signup partial templates 438 Logging ■

in and saving the session state 439 Gate-keeping the


actions with before_filter 441 Implementing a signing-up


facility 444 Scripting customer logout 445


16.5 Processing customer orders 446


The view_cart action and template 446 Viewing and

buying an edition 448 Defining the add_to_cart


action 449 Completing the order(s) 449


16.6 Personalizing the page via dynamic code 450


From rankings to favorites 450 ■ The favorites
feature in action 452
16.7 Summary 454

17 Techniques for exploring the Rails source code 455


17.1 Exploratory technique 1: panning for info
Sample info panning: belongs_to 457
456

17.2 Exploratory technique 2: shadowing Ruby 458


Choosing a starting point 458 Choose among forks in the

road intelligently 459 On the trail of belongs_to 460


A transliteration of belongs_to 463


17.3 Exploratory technique 3: consulting the
documentation 464
A roadmap of the online Rails API documentation 466
17.4 Summary 469

appendix Ruby and Rails installation and resources 471


index 477
foreword
I can’t learn a language for the sake of it. I need to have a concrete desire to do some-
thing with it—to solve a problem or a task, to create something of value... That’s how
I got into Ruby around the summer of 2003. I wanted to build a Web application and
decided this was the perfect opportunity to learn Ruby. That Web application was
Basecamp, which eventually served as the point of extraction for Rails.
Coming from PHP and Java, I remember how many of Ruby’s most wonderful
features seemed odd at first. “What is it exactly that makes blocks so special?” I
thought. “They’re just convenience for writing a line of code at the beginning and
the end.” Little did I know... As I started using Ruby and extracting Rails, I quickly
wised up. Ruby is such an incredibly rich and expressive language that it’s hard to
appreciate its beauty by simply relating it to past experiences with other languages.
To create Basecamp, I needed to live and breathe Ruby. And when I did, I kept
finding aspects of the language that were exactly what I needed for the situation
at hand. Tasks that would have made my eyes roll in PHP or Java made my smile
light up as Ruby time and time again showed that programming could be simple,
fun, and outright beautiful.
As I was learning the language, I often consulted the ruby-talk mailing list. One
voice in particular seemed to know Ruby well and appeared to have the ambition
as well as the ability to help others understand it more fully. That voice belonged
to David A. Black, the author of this book.

xix
xx FOREWORD

David clearly has an encyclopedic knowledge of Ruby. Not only does he under-
stand how to use it, but he can also explain why things are the way they are. He
connects the dots and allows you to see the bigger picture, providing the missing
piece that turns puzzle into picture. I couldn’t imagine a better person to write
Ruby for Rails. It’s a great honor to have the man who taught me so much about
Ruby now help others understand the language for use with my framework.
This is the book that everyone coming from another language to Rails should
have. To fully realize the potential of Rails, it’s crucial that you take the time to
fully understand Ruby—and with Ruby for Rails David has provided just what you
need to help you achieve that goal.

DAVID HEINEMEIER HANSSON


Creator of Ruby on Rails
Partner at 37signals
preface
When the editors at Manning asked me whether I thought the time was ripe for a
new Ruby book, and if so, what it should be about and who should write it, I
answered:
“Yes.... A Ruby language book purpose-written for Rails practitioners.... Me.”
They agreed.
I warmly welcomed the opportunity. I’d been thinking along “Ruby for Rails”
lines since I started using the Ruby on Rails framework in the Fall of 2004 (which,
by the way, makes me an almost-early adopter). Rails had been first released that
summer, and I learned about it from the presentation by David Heinemeier Hans-
son, the creator of Rails, at the 2004 International Ruby Conference.
Ruby for Rails sounds like it might mean “…as opposed to regular Ruby,” a tool
for dividing Ruby users into Rails and non-Rails camps. I saw it as the opposite:
real Ruby, regular Ruby, on its own terms, but studied primarily because of what it
can do for Rails developers. I was in a good position to understand the potential
of this approach: I’d been programming in Ruby for almost four years before I
started using Rails; and when I did start using it, I quickly gained a view of how a
deeper knowledge of Ruby could help Rails programmers achieve their goals.
An alarm went off in my head, therefore, when I saw how many budding Rails
developers were asking themselves whether it was necessary to learn Ruby in order
to use Rails. The fact that this question was the subject of disagreement and
debate surprised me. And it suggested a couple of points.

xxi
xxii PREFACE

First, there was clearly room for education about the basics: that Rails is written
in Ruby, and Rails applications are written in Ruby, so if you’re writing Rails appli-
cations, you’ve already decided to use Ruby. Second, I could see the beginnings of an
inadvertent, self-imposed quarantine on the part of these Rails developers (who
were perfectly well-intentioned, but not in possession of the full picture) and I saw
that something could and should be done about it. People were talking themselves
into living under a glass ceiling, where they could get Rails applications to run and
do some reasonably adroit things with Rails techniques and idioms, but where they
were denying themselves the chance to deploy the full power of Ruby—the lan-
guage which they were in fact already using. That needed to be addressed.
I also noticed a large number of questions in various forums (and various
forms) along the lines of “I know I’m supposed to write belongs_to :customer,
but what is that?” A number of Rails users told me that they were able to get appli-
cations up and running by imitating and adapting lines of code from other appli-
cations, but they were finding it unsatisfying because they didn’t feel they knew
what was going on. The fact that people were having trouble understanding Rails
code in Ruby terms meant that they were not in a position to go to the next level:
using the full power of Ruby to enhance and extend the functionality of their
Rails applications.
It occurred to me that a Rails-centric Ruby language tutorial could serve the
dual roles of, first, explaining to Rails developers who didn’t yet see that Ruby and
Rails don’t reside in separate silos but, rather, enjoy a parent/child technology rela-
tionship with extremely open lines of communication; and, second, smashing the
glass ceiling that separated Rails people from using Ruby more effectively.
As the book project got under way, my goal became to explain that the learn-
ing of Ruby by a “Rails person” is an entirely additive, win-win proposition. It
doesn’t mean Rails has some deficiency that has to be compensated for by know-
ing a foreign technology. Rather, Rails has a tremendous strength—the strength
of having been written in an elegant, concise, very approachable programming
language—the implications of which for day-to-day Rails programming are impor-
tant and are a pleasure to explore.
Thus Ruby for Rails: a reaffirmation and explanation of the way things stand,
and have always stood, between the language and the framework, and an invita-
tion to shatter that glass ceiling.
acknowledgments
This book has benefited from support of many kinds from many quarters.
At Manning Publications, assistant acquisitions editor Megan Yockey and pub-
lisher’s assistant Blaise Bace saw me ably and enthusiastically through the proposal
and contract phases of the project. I worked initially, and productively, with devel-
opment editor Doug Bennett; subsequently, for reasons of scheduling and logis-
tics, my project was reassigned to development editor Lianna Wlasiuk, who
worked with me in an intense, sustained way through the writing of the book, cou-
pling a marvelous collegiality with a gentle but firm refusal to settle for anything
other than a strong, polished product.
Review editor Karen Tegtmeyer sought, and found, specialists from both the
Ruby and Rails spheres to review the manuscript at the various prescribed phases
of partial completion—a process I like to think I became less surly about, the
more evidence I saw of how materially helpful it could be. Book designer Dottie
Marsico worked with me on the illustrations; I have Dottie to thank for my new-
found OpenOffice Draw skills as well as for her encouragement and quick respon-
siveness to questions and concerns.
As the book moved through the latter stages of preparation and into the pro-
duction stages, I had the indispensable support and help of production director
Mary Piergies, who coordinated the geographically far-flung process in a way that
brought it unity and momentum. To copy editor Tiffany Taylor I can pay no
greater tribute than to say that I quickly got into the habit of telling OpenOffice
to hide the history of changes in the document and only show me the text as it

xxiii
xxiv ACKNOWLEDGMENTS

appeared after Tiffany had worked on it. I have no doubt, moreover, that several
trees owe their lives to Tiffany’s ability to trim away excess verbiage.
Technical proofreader Bruce Williams made numerous suggestions and cor-
rections which, I can assure readers, have measurably improved the readability of
the code samples as well as the text. There’s nothing like a keen second set of
eyes, and a second tester, to convince one, once and for all, that one really must
not make little changes to code after cutting-and-pasting it in….
I worked with three proofreaders. Elizabeth R. Martin, who kindly stepped in to
tide the project over during a scheduling gap, brought a sharp eye to bear on the
book’s first chapters. The balance of the manuscript was proofread by Elizabeth
Welch, on whom I have relied not only for error-catching but for constant consul-
tation in discretionary matters of typographical consistency and style. Barbara
Mirecki gave the manuscript a close, skillful final read. Katie Tennant brought a
professional’s skill and care to bear on my well-intentioned, but inevitably imper-
fect, indexing efforts. Typesetter Gordan Salinovic has worked diligently and
responsively with us to ensure a consistent, reader-friendly look.
Manning webmaster Iain Shigeoka worked behind the scenes to keep the infor-
mation flow going among the various members of the production team and me,
and quickly stepped up to help on the few occasions when glitches cropped up.
On the marketing side, Manning’s sales and marketing chief Ron Tomich and
marketing director Helen Trimes have kept the book before the Ruby/Rails pub-
lic eye and have sought my input and collaboration throughout the process. As
much as the popularity of Ruby and Rails can help, there’s no such thing as a
book that promotes itself, and Helen and Ron have been anything but compla-
cent in getting the word out.
Last but by no means least among the members of the Manning team to whom
I offer my thanks is publisher Marjan Bace, who saw the viability of this project
quickly, supported it unreservedly, and piloted it skillfully through many ups and
a sprinkling of downs. Both the book and I benefited from Marjan’s availability,
attentiveness, and mastery of the contours of the publication landscape.
I’d like to thank the reviewers of the original book proposal and all of the out-
side readers who participated in the various partial-manuscript review cycles. Many
of the comments and criticisms of the latter group had more of an impact on the
book than they themselves might have anticipated. Thanks go to Anjan Bacchu,
Christopher Bailey, Jamis Buck, Stuart Caborn, Tom Copeland, Ryan Cox, Jeff
Cunningham, Pat Dennis, Mark Eagle, Sasa Ebach, Shaun Fanning, Hal Fulton,
Benjamin Gorlick, Erik Hatcher, David Heinemeier Hansson, Jack Herrington,
Bob Hutchison, Duane Johnson, Albert Koscielny, Robert McGovern, Andrew
Random documents with unrelated
content Scribd suggests to you:
principium individuationis, like a kaleidoscope, shows us in ever-
shifting evanescent forms, there is an underlying unity, not only truly
existing, but actually accessible to us; for lo! in tangible, objective
form, it stands before our sight.
Of these two mental attitudes, according as the one or the other is
adopted, so the ϕιλία (Love) or the νεῑκος (Hatred) of Empedocles
appears between man and man. If any one, who is animated by
νεῑκος, could forcibly break in upon his most detested foe, and
compel him to lay bare the inmost recesses of his heart; to his
surprise, he would find again in the latter his very self. For just as in
dreams, all the persons that appear to us are but the masked
images of ourselves; so in the dream of our waking life, it is our own
being which looks on us from out our neighbours' eyes,—though this
is not equally easy to discern. Nevertheless, tat tvam asi.
The preponderance of either mode of viewing life not only
determines single acts; it shapes a man's whole nature and
temperament. Hence the radical difference of mental habit between
the good character and the bad. The latter feels everywhere that a
thick wall of partition hedges him off from all others. For him the
world is an absolute non-ego, and his relation to it an essentially
hostile one; consequently, the key-note of his disposition is hatred,
suspicion, envy, and pleasure in seeing distress. The good character,
on the other hand, lives in an external world homogeneous with his
own being; the rest of mankind is not in his eyes a non-ego; he
thinks of it rather as "myself once more." He therefore stands on an
essentially amicable footing with every one: he is conscious of being,
in his inmost nature, akin to the whole human race,[9] takes direct
interest in their weal and woe, and confidently assumes in their case
the same interest in him. This is the source of his deep inward
peace, and of that happy, calm, contented manner, which goes out
on those around him, and is as the "presence of a good diffused."
Whereas the bad character in time of trouble has no trust in the help
of his fellow-creatures. If he invokes aid, he does so without
confidence: obtained, he feels no real gratitude for it; because he
can hardly discern therein anything but the effect of others' folly. For
he is simply incapable of recognising his own self in some one else;
and this, even after it has furnished the most incontestible signs of
existence in that other person: on which fact the repulsive nature of
all unthankfulness in reality depends. The moral isolation, which thus
naturally and inevitably encompasses the bad man, is often the
cause of his becoming the victim of despair. The good man, on the
contrary, will appeal to his neighbours for assistance, with an
assurance equal to the consciousness he has of being ready himself
to help them. As I have said: to the one type, humanity is a non-
ego; to the other, "myself once more." The magnanimous character,
who forgives his enemy, and returns good for evil, rises to the
sublime, and receives the highest meed of praise; because he
recognises his real self even there where it is most conspicuously
disowned.
Every purely beneficent act all help entirely and genuinely unselfish,
being, as such, exclusively inspired by another's distress, is, in fact,
if we probe the matter to the bottom, a dark enigma, a piece of
mysticism put into practice; inasmuch as it springs out of, and finds
its only true explanation in, the same higher knowledge that
constitutes the essence of whatever is mystical.
For how, otherwise than metaphysically, are we to account for even
the smallest offering of alms made with absolutely no other object
than that of lessening the want which afflicts a fellow-creature? Such
an act is only conceivable, only possible, in so far as the giver
knows that it is his very self which stands before him, clad in the
garments of suffering; in other words, so far as he recognises the
essential part of his own being, under a form not his own.[10] It now
becomes apparent, why in the foregoing part I have called
Compassion the great mystery of Ethics.
He, who goes to meet death for his fatherland, has freed himself
from the illusion which limits a man's existence to his own person.
Such a one has broken the fetters of the principium individuationis.
In his widened, enlightened nature he embraces all his countrymen,
and in them lives on and on. Nay, he reaches forward to, and
merges himself in the generations yet unborn, for whom he works;
and he regards death as a wink of the eyelids, so momentary that it
does not interrupt the sight.
We may here sum up the characteristics of the two human types
above indicated. To the Egoist all other people are uniformly and
intrinsically strangers. In point of fact, he considers nothing to be
truly real, except his own person, and regards the rest of mankind
practically as troops of phantoms, to whom he assigns merely a
relative existence, so far as they may be instruments to serve, or
barriers to obstruct, his purposes; the result being an immeasurable
difference, a vast gulf between his ego on the one side, and the
non-ego on the other. In a word, he lives exclusively centred in his
own individuality, and on his death-day he sees all reality, indeed the
whole world, coming to an end along with himself.[11] Whereas the
Altruist discerns in all other persons, nay, in every living thing, his
own entity, and feels therefore that his being is commingled, is
identical with the being of whatever is alive. By death he loses only a
small part of himself. Patting off the narrow limitations of the
individual, he passes into the larger life of all mankind, in whom he
always recognised, and, recognising, loved, his very self; and the
illusion of Time and Space, which separated his consciousness from
that of others, vanishes. These two opposite modes of viewing the
world are probably the chief, though not indeed the sole cause of
the difference we find between very good and exceptionally bad
men, as to the manner in which they meet their last hour.
In all ages Truth, poor thing, has been put to shame for being
paradoxical; and yet it is not her fault. She cannot assume the form
of Error seated on his throne of world-wide sovereignty. So then,
with a sigh, she looks up to her tutelary god, Time, who nods
assurance to her of future victory and glory, but whose wings beat
the air so slowly with their mighty strokes, that the individual
perishes or ever the day of triumph be come. Hence I, too, am
perfectly aware of the paradox which this metaphysical explanation
of the ultimate ethical phaenomenon must present to Western
minds, accustomed, as they are, to very different methods of
providing Morals with a basis. Nevertheless, I cannot offer violence
to the truth. All that is possible for me to do, out of consideration for
European blindness, is to assert once more, and demonstrate by
actual quotation, that the Metaphysics of Ethics, which I have here
suggested, was thousands of years ago the fundamental principle of
Indian wisdom. And to this wisdom I point back, as Copernicus did
to the Pythagorean cosmic system, which was suppressed by
Aristotle and Ptolemaeus. In the Bhagavadgîtâ (Lectio XIII.; 27, 28),
according to A. W. von Schlegel's translation, we find the following
passage: Eundem in omnibus animantibus consistentem summum
dominum, istis pereuntibus kaud pereuntem qui cernit, is vere cernit.
Eundem vero cernens ubique praesentem dominum, non violat
semet ipsum sua ipsius culpa: exinde pergit ad summum iter.[12]
With these hints towards the elaboration of a metaphysical basis for
Ethics I must close, although an important step still remains to be
taken. The latter would presuppose a further advance in Moral
Science itself; and this can hardly be made, because in the West the
highest aim of Ethics is reached in the theory of justice and virtue.
What lies beyond is unknown, or at any rate ignored. The omission,
therefore, is unavoidable; and the reader need feel no surprise, if
the above slight outline of the Metaphysics of Ethics does not bring
into view—even remotely—the corner-stone of the whole
metaphysical edifice, nor reveal the connection of all the parts
composing the Divina Commedia. Such a presentment, moreover, is
involved neither in the question set, nor in my own plan. A man
cannot say everything in one day, and should not answer more than
he is asked.
He who tries to promote human knowledge and insight is destined to
always encounter the opposition of his age, which is like the dead
weight of some mass that has to be dragged along: there on the
ground it lies, a huge inert deformity, defying all efforts to quicken
its shape with new life. But such a one must take comfort from the
certainty that, although prejudices beset his path, yet the truth is
with him. And Truth does but wait for her ally, Time, to join her;
once he is at her side, she is perfectly sure of victory, which, if to-
day delayed, will be won to-morrow.

[1] The conception of the Good, in its purity, is an ultimate one, "an absolute Idea,
whose substance loses itself in infinity."—(Bouterweek: Praktische Aphorismen, p.
54.)
It is obvious that this writer would like to transform the familiar, nay, trivial
conception "Good" into a sort of Διἴπετής, to be set up as an idol in his temple.
Διἴπετής lit., "fallen from Zeus"; and so "heaven-sent," "a thing of divine origin."
Cf. Horn., Il.. XVI, 174; Od.. IV. 477. Eur., Bacch., 1268.—(Translator.)
[2]The genuineness of the O u p n e k ' h a t has been disputed on the ground of
certain marginal glosses which were added by Mohammedan copyists, and then
interpolated in the text, it has, however, been fully established by the Sanskrit
scholar, F.H.H. Windischmann (junior) in his Sancara, sive de Theologumenis
Vedanticorum, 1833, p. xix; and also by Bochinger in his book De la Vie
Contemplative chez les Indous, 1831, p. 12. The reader though ignorant of
Sanskrit, may yet convince himself that Anquetil Duperron's word for word Latin
translation of the Persian version of the U p a n i s h a d s made by the martyr of
this creed, the Sultan D â r â - S h u k o h, is based on a thorough and exact
knowledge of the language. He has only to compare it with recent translations of
some of the U p a n i s h a d s by Rammohun Boy, by Poley, and especially with that
of Colebrooke, as also with Röer's, (the latest). These writers are obviously
groping in obscurity, and driven to make shift with hazy conjectures, so that
without doubt their work is much less accurate. More will be found on this subject
in Vol. II. of the Parerga, chap. 16, § 184. [V. The Upanishads, translated by Max
Müller, in The Sacred Books of the East, Vols. I. and XV. Cf. also Max Müller, The
Science of Language, Vol. I., p. 171. Now that an adequate translation of the
original exists, the O u p n e k ' h a t has only an historical interest. The value which
Schopenhauer attached to the U p a n i s h a d s is very clearly expressed also in the
Welt als Wille und Vorstellung, Preface to the first Edition; and in the Parerga, II.,
chap, xvi., § 184.—(Translator.)]
[3] For the S û f i, more correctly *Sūfīy a sect which appeared already in the first
century of the H i j r a h, the reader is referred to: Tholuck's Blüthensammlung aus
der Morgenländischen Mystik (Berlin, 1825); Tholuck's Sûfismus, sive Theosophia
Persarum Pantheistica (Berlin, 1821); Kremer's Geschichte der Herrschenden
Ideen des Islâms (Leipzig, 1868); Palmer's Oriental Mysticism (London, 1867);
Gobineau's Les Religions et les Philosophies dans l'Asie Centrale (2nd edit. Paris,
1866); A Dictionary of Islâm, by T. P. Hughes (London, 1885), p. 608 sqq.—
(Translator.)
[4] This is too well-known to need verification by references. The Cantico del Sole
by St. Francis of Assisi sounds almost like a passage from the U p a n i s h a d s or
the B h a g a v a d g î t â.—(Translator.)
[5]
On peut assez longtemps, chez notre espèce,
Fermer la porte à la Raison.
Mais, dès qu'elle entre avec adresse,
Elle reste dans la maison,
Et bientôt elle en est maîtresse.
—(Voltaire.)
(We men may, doubtless, all our lives
To Reason bar the door.
But if to enter she contrives,
The house she leaves no more,
And soon as mistress there presides.)
[6] Τὸ ἔν= the eternal Reality outside Time and Space Tὸ πᾱν = the phaenomenal
universe.—(Translator.)
[7] Mâyâ is "the delusive reflection of the true eternal Entity."—(Translator.)
[8] This expression is used in the Brahmanical philosophy to denote the relation
between the world-fiction as a whole and its individualised parts. V. A. E. Gough,
Philosophy of the Upanishads, 1882.—(Translator.)
[9] Homo sum: humani nil a me alienum puto. Terence, Heaut., I. 1, 25.—
(Translator.)
[10] It is probable that many, perhaps, most cases of truly disinterested
Compassion—when they really occur—are due not to any conscious knowledge of
this sort, but to an unconscious impulse springing from the ultimate unity of all
living things, and acting, so to say, automatically.—(Translator.)
[11] Cf. Richard Wagner: Jesus von Nazareth; pp. 79-90.—(Translator.)
[12] That man is endowed with true insight who sees that the same ruling power
is inherent in all things, and that when these perish, it perishes not. For if he
discerns the same ruling power everywhere present, he does not degrade himself
by his own fault: thence he passes to the highest path.—For the Bhagavadgîtâ the
reader is referred to Vol. VIII. of The Sacred Books of the East (Oxford: Clarendon
Press), where (p. 105) this passage is translated as follows:—"He sees (truly) who
sees the supreme lord abiding alike in all entities, and not destroyed though they
are destroyed. For he who sees the lord abiding everywhere alike, does not
destroy himself[*] by himself, and then reaches the highest goal."
[*]"Not to have true knowledge, is equivalent to self-destruction."
Cf. Fauche: Le Mahā-bhārata: Paris, 1867; Vol. VII., p. 128:—
"Celui-là possède une vue nette des choses, qui voit ce principe souverain en tous
les êtres d'une manière égale, et leur survivre, quand ils périssent. Il ne se fait
aucun tort à soi-même par cette vue d'un principe qui subsiste également partout:
puis, après cette vie, il entre dans la voie supérieure."
The obscurity of Schlegel's Latin in the second sentence is sufficiently removed by
these more recent translations.—(Translator.)

JUDICIUM

REGIAE DANICAE SCIENTIARUM SOCIETATIS.

Quaestionem anno 1837 propositam, "utrum philosophiae moralis


fons et fundamentum in idea moralitatis, quae immediate conscientia
contineatur, et ceteris notionibus fundamentalibus, quae ex ilia
prodeant, explicandis quaerenda sint, an in alio cognoscendi
principio," unus tantum scriptor explicare conatus est, cujus
commentationem, germanico sermone compositam, et his verbis
notatam: "MORAL PREDIGEN IST LEICHT, MORAL BEGRÜNDEN IST SCHWER,"
praemio dignam judicare nequivimus. Omisso enim eo, quod
potissimum postulabatur, hoc expeti putavit, ut principium aliquod
ethicae conderetur, itaqae eam partem commentationis suae, in qua
principii ethicae a se propositi et metaphysicae suae nexum exponit,
appendices loco habuit, in qua plus quam postulatum esset
praestaret, quum tamen ipsum thema ejusmodi disputationem
flagitaret, in qua vel praecipuo loco metaphysicae et ethicae nexus
consideraretur. Quod autem scriptor in sympathia fundamentum
ethicae constituere conatus est, neque ipsa disserendi forma nobis
satisfecit, neque reapse, hoc fundamentum sufficere, evicit; quin
ipse contra esse confiteri coactus est. Neque reticendum videtur,
plures recentioris aetatis summos philosophos tam indecenter
commemorari, ut justam et gravem offensionem habeat.
JUDGMENT OF THE DANISH ROYAL SOCIETY OF SCIENCES.

In 1837 the following question was set as subject for a Prize Essay:
"Is the fountain and basis of Morals to be sought for in an idea of
morality which lies directly in the consciousness (or conscience), and
in the analysis of the other leading ethical conceptions which arise
from it? Or is it to be found in some other source of knowledge?"
There was only one competitor; but his dissertation, written in
German, and bearing the motto: "To preach Morality is easy, to
found it is difficult"[1] we cannot adjudge worthy of the Prize. He has
omitted to deal with the essential part of the question, apparently
thinking that he was asked to establish some fundamental principle
of Ethics. Consequently, that part of the treatise, which explains how
the moral basis he proposes is related to his system of metaphysics,
we find relegated to an appendix, as an "opus supererogationis,"
although it was precisely the connection between Metaphysics and
Ethics that our question required to be put in the first and foremost
place. The writer attempts to show that compassion is the ultimate
source of morality; but neither does his mode of discussion appear
satisfactory to us, nor has he, in point of fact, succeeded in proving
that such a foundation is adequate. Indeed he himself is obliged to
admit that it is not.[2] Lastly, the Society cannot pass over in silence
the fact that he mentions several recent philosophers of the highest
standing in an unseemly manner, such as to justly occasion serions
offence.

[1] The Academy has been good enough to insert the second "is" on its own
account, by way of proving the truth of Longinus' theory (V. De Sublimitate: chap.
39, ad fin.), that the addition or subtraction of a single syllable is sufficient to
destroy the whole force of a sentence. (P. Longinus: De Sublimitate Libellus; edit.
Joannes Vablen, Bonnae, 1887.)—(Translator)
[2] I suppose this is the meaning of contra esse confiteri.— (Translator.)
*** END OF THE PROJECT GUTENBERG EBOOK THE BASIS OF
MORALITY ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
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

You might also like