9780321832054

Ruby on Rails Tutorial Learn Web Development with Rails

by
  • ISBN13:

    9780321832054

  • ISBN10:

    0321832051

  • Edition: 2nd
  • Format: Paperback
  • Copyright: 7/27/2012
  • Publisher: Addison-Wesley Professional
  • View Upgraded Edition
  • Purchase Benefits
  • Free Shipping On Orders Over $59!
    Your order must be $59 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $44.99

Summary

Rails has rapidly become one of the world's most popular web development frameworks. But Rails can be challenging - and, until now, there's been no good way to learn modern Rails development from the ground up. Ruby on Rails 3 Tutorial 2/e fills that enormous gap. Leading expert Michael Hartl teaches today's Rails best practices by walking readers through the construction of a complete application - from start to finish. Ruby on Rails 3 Tutorial 2/e is the first book to show developers how to take full advantage of the latest Rails 3.2 innovations - including techniques that make Rails development easier and more accessible. Hartl covers all facets of application design and implementation, addressing issues ranging from content management and e-commerce to CRM and Railscasts. Developers see each technique in real-world context, motivated by realistic problems. Hartl introduces new concepts at just the right pace, moving from the basics through advanced topics. The new edition has been updated to include: * Fully updated for Rails 3.2 and Ruby 1.9 * Coverage of the new asset pipeline * Behavior-driven development (BDD) with Capybara and RSpec * Introduction to Sass (Syntactically Awesome Stylesheets) * Better automated testing with Guard and Spork * Rolling your own authentication system with has_secure_password * An introduction to writing client-friendly tests with Cucumber

Author Biography

Michael Hartl is a programmer, educator, and entrepreneur. He wrote the first edition of Ruby on Rails Tutorial (Addison-Wesley, 2011), coauthored RailsSpace (Addison-Wesley, 2008), and was cofounder and lead developer of Insoshi, a popular social networking platform based on Rails. He previously taught theoretical and computational physics at the California Institute of Technology, earning the Caltech Lifetime Achievement Award for Excellence in Teaching. Michael is a graduate of Harvard College, holds a Ph.D. in physics from Caltech, and is an alumnus of the Y Combinator entrepreneur program.

Table of Contents

Foreword to the First Editionp. xv
Foreword to the First Editionp. xvii
Acknowledgmentsp. xix
About the Authorp. xxi
From Zero to Deployp. 1
Introductionp. 3
Comments for Various Readersp. 4
"Scaling" Railsp. 7
Conventions in This Bookp. 7
Up and Runningp. 9
Development Environmentsp. 10
Ruby, RubyGems, Rails, and Gitp. 12
The First Applicationp. 17
Bundlerp. 19
rails serverp. 23
Model-view-controller (MVC)p. 25
Version Control with Gitp. 27
Installation and Setupp. 27
Adding and Committingp. 30
What Good Does Git Do You?p. 31
GitHubp. 32
Branch, Edit, Commit, Mergep. 34
Deployingp. 39
Heroku Setupp. 39
Heroku Deployment, Step Onep. 40
Heroku Deployment, Step Twop. 40
Heroku Commandsp. 41
Conclusionp. 43
A Demo Appp. 45
Planning the Applicationp. 45
Modeling Demo Usersp. 47
Modeling Demo Micropostsp. 48
The Users Resourcep. 49
A User Tourp. 51
MVC in Actionp. 56
Weaknesses of this Users Resourcep. 62
The Microposts Resourcep. 63
A Micropost Microtourp. 63
Putting the micro in Micropostsp. 66
A User has_many Micropostsp. 68
Inheritance Hierarchiesp. 70
Deploying the Demo Appp. 73
Conclusionp. 74
Mostly Static Pagesp. 77
Static Pagesp. 82
Truly Static Pagesp. 82
Static Pages with Railsp. 85
Our First Testsp. 93
Test-driven Developmentp. 93
Adding a Pagep. 99
Slightly Dynamic Pagesp. 103
Testing a Tide Changep. 103
Passing Tide Testsp. 106
Embedded Rubyp. 108
Eliminating Duplication with Layoutsp. 111
Conclusionp. 114
Exercisesp. 114
Advanced Setupp. 117
Eliminating bundle execp. 118
Automated Tests with Guardp. 120
Speeding up Tests with Sporkp. 123
Tests inside Sublime Textp. 127
Rails-Flavored Rubyp. 129
Motivationp. 129
Strings and Methodsp. 134
Commentsp. 134
Stringsp. 135
Objects and Message Passingp. 138
Method Definitionsp. 141
Back to the Title Helperp. 142
Other Data Structuresp. 142
Arrays and Rangesp. 142
Blocksp. 146
Hashes and Symbolsp. 148
CSS revisitedp. 152
Ruby Classesp. 153
Constructorsp. 153
Class Inheritancep. 155
Modifying Built-in Classesp. 158
A Controller Classp. 159
A User Classp. 161
Conclusionp. 164
Exercisesp. 164
Filling in the Layoutp. 167
Adding Some Structurep. 167
Site Navigationp. 169
Bootstrap and Custom CSSp. 175
Partialsp. 181
Sass and the Asset Pipelinep. 187
The Asset Pipelinep. 187
Syntactically Awesome Stylesheetsp. 190
Layout Linksp. 197
Route Testsp. 200
Rails Routesp. 202
Named Routesp. 205
Pretty RSpecp. 207
User Signup: A First Stepp. 211
Users Controllerp. 212
Signup URIp. 213
Conclusionp. 215
Exercisesp. 217
Modeling Usersp. 221
User Modelp. 222
Database Migrationsp. 223
The Model Filep. 228
Creating User Objectsp. 230
Finding User Objectsp. 233
Updating User Objectsp. 235
User Validationsp. 236
Initial User Testsp. 236
Validating Presencep. 239
Length Validationp. 243
Format Validationp. 245
Uniqueness Validationp. 249
Adding a Secure Passwordp. 254
An Encrypted Passwordp. 255
Password and Confirmationp. 257
User Authenticationp. 260
User Has Secure Passwordp. 263
Creating a Userp. 265
Conclusionp. 267
Exercisesp. 268
Sign Upp. 271
Showing Usersp. 271
Debug and Rails Environmentsp. 272
A Users Resourcep. 278
Testing the User Show Page (with Factories)p. 282
A Gravatar Image and a Sidebarp. 286
Signup Formp. 292
Tests for User Signupp. 293
Using form_forp. 297
The Form HTMLp. 301
Signup Failurep. 303
A Working Formp. 303
Signup Error Messagesp. 308
Signup Successp. 312
The Finished Signup Formp. 313
The Flashp. 315
The First Signupp. 317
Deploying to Production with SSLp. 317
Conclusionp. 321
Exercisesp. 321
Sign In, Sign Outp. 325
Sessions and Signin Failurep. 325
Sessions Controllerp. 326
Signin Testsp. 330
Signin Formp. 333
Reviewing Form Submissionp. 336
Rendering with a Flash Messagep. 339
Signin Successp. 343
Remember Mep. 343
A Working sign_in Methodp. 349
Current Userp. 351
Changing the Layout Linksp. 355
Signin upon Signupp. 359
Signing Outp. 361
Introduction to Cucumber (Optional)p. 363
Installation and Setupp. 364
Features and Stepsp. 365
Counterpoint: RSpec Custom Matchersp. 368
Conclusionp. 371
Exercisesp. 372
Updating, Showing, and Deleting Usersp. 373
Updating Usersp. 373
Edit Formp. 374
Unsuccessful Editsp. 380
Successful Editsp. 382
Authorizationp. 385
Requiring Signed-in Usersp. 386
Requiring the Right Userp. 390
Friendly Forwardingp. 392
Showing All Usersp. 396
User Indexp. 396
Sample Usersp. 403
Paginationp. 404
Partial Refactoringp. 410
Deleting Usersp. 413
Administrative Usersp. 413
The destroy Actionp. 417
Conclusionp. 422
Exercisesp. 424
User Micropostsp. 429
A Micropost Modelp. 429
The Basic Modelp. 430
Accessible Attributes and the First Validationp. 432
User/Micropost Associationsp. 433
Micropost Refinementsp. 439
Content Validationsp. 443
Showing Micropostsp. 445
Augmenting the User Show Pagep. 446
Sample Micropostsp. 450
Manipulating Micropostsp. 454
Access Controlp. 456
Creating Micropostsp. 459
A Proto-feedp. 467
Destroying Micropostsp. 475
Conclusionp. 479
Exercisesp. 480
Following Usersp. 483
The Relationship Modelp. 484
A Problem with the Data Model (and a Solution)p. 485
User/Relationship Associationsp. 491
Validationsp. 495
Followed usersp. 495
Followersp. 500
A Web Interface for Following Usersp. 503
Sample Following Datap. 503
Stats and a Follow Formp. 505
Following and Followers Pagesp. 515
A Working Follow Button the Standard Wayp. 519
A Working Follow Button with Ajaxp. 524
The Status Feedp. 529
Motivation and Strategyp. 530
A First Feed Implementationp. 532
Subselectsp. 535
The New Status Feedp. 538
Conclusionp. 539
Extensions to the Sample Applicationp. 540
Guide to Further Resourcesp. 542
Exercisesp. 543
Indexp. 545
Table of Contents provided by Ingram. All Rights Reserved.

Rewards Program

Write a Review