"Ruby on Rails (TM) Tutorial by Michael Hartl has become a must-read for developers learning how to build Rails apps."
--Peter Cooper, Editor of Ruby Inside
Used by sites as varied as Hulu, GitHub, Shopify, and Airbnb, Ruby on Rails is one of the most popular frameworks for developing web applications, but it can be challenging to learn and use. Whether you're new to web development or new only to Rails, Ruby on Rails (TM) Tutorial, Seventh Edition, is the solution.
Best-selling author and leading Rails developer Michael Hartl teaches Rails by guiding you through the development of three example applications of increasing sophistication. The tutorial's examples focus on the general principles of web development needed for virtually any kind of website. The updates to this edition include full compatibility with Rails 7.
This indispensable guide provides integrated tutorials not only for Rails, but also for the essential Ruby, HTML, CSS, and SQL skills you need when developing web applications. Hartl explains how each new technique solves a real-world problem, and then he demonstrates it with bite-sized code that's simple enough to understand while still being useful. Whatever your previous web-development experience, this book will guide you to true Rails mastery.
This book will help you
Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.
Show more"Ruby on Rails (TM) Tutorial by Michael Hartl has become a must-read for developers learning how to build Rails apps."
--Peter Cooper, Editor of Ruby Inside
Used by sites as varied as Hulu, GitHub, Shopify, and Airbnb, Ruby on Rails is one of the most popular frameworks for developing web applications, but it can be challenging to learn and use. Whether you're new to web development or new only to Rails, Ruby on Rails (TM) Tutorial, Seventh Edition, is the solution.
Best-selling author and leading Rails developer Michael Hartl teaches Rails by guiding you through the development of three example applications of increasing sophistication. The tutorial's examples focus on the general principles of web development needed for virtually any kind of website. The updates to this edition include full compatibility with Rails 7.
This indispensable guide provides integrated tutorials not only for Rails, but also for the essential Ruby, HTML, CSS, and SQL skills you need when developing web applications. Hartl explains how each new technique solves a real-world problem, and then he demonstrates it with bite-sized code that's simple enough to understand while still being useful. Whatever your previous web-development experience, this book will guide you to true Rails mastery.
This book will help you
Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.
Show moreForeword xvii
Preface xix
Acknowledgments xxv
About the Author xxvii
Chapter 1: From Zero to Deploy 1
1.1 Up and Running 5
1.2 The First Application 14
1.3 Version Control with Git 35
1.4 Deploying 52
1.5 Conclusion 61
1.6 Conventions Used in This Book 62
Chapter 2: A Toy App 65
2.1 Planning the Application 66
2.2 The Users Resource 71
2.3 The Microposts Resource 87
2.4 Conclusion 104
Chapter 3: Mostly Static Pages 107
3.1 Sample App Setup 107
3.2 Static Pages 115
3.3 Getting Started with Testing 126
3.4 Slightly Dynamic Pages 135
3.5 Conclusion 152
3.6 Advanced Testing Setup 153
Chapter 4: Rails-Flavored Ruby 159
4.1 Motivation 159
4.2 Strings and Methods 165
4.3 Other Data Structures 177
4.4 Ruby Classes 192
4.5 Conclusion 204
Chapter 5: Filling in the Layout 207
5.1 Adding Some Structure 207
5.2 Sass and the Asset Pipeline 232
5.3 Layout Links 242
5.4 User Signup: A First Step 255
5.5 Conclusion 260
Chapter 6: Modeling Users 263
6.1 User Model 264
6.2 User Validations 279
6.3 Adding a Secure Password 303
6.4 Conclusion 313
Chapter 7: Sign Up 315
7.1 Showing Users 316
7.2 Signup Form 337
7.3 Unsuccessful Signups 346
7.4 Successful Signups 361
7.5 Professional-Grade Deployment 374
7.6 Conclusion 380
Chapter 8: Basic Login 381
8.1 Sessions 381
8.2 Logging In 398
8.3 Logging Out 437
8.4 Conclusion 443
Chapter 9: Advanced Login 445
9.1 Remember Me 445
9.2 "Remember Me" Checkbox 470
9.3 Remember Tests 476
9.4 Conclusion 489
Chapter 10: Updating, Showing, and Deleting Users
493
10.1 Updating Users 493
10.2 Authorization 509
10.3 Showing All Users 526
10.4 Deleting Users 544
10.5 Conclusion 556
Chapter 11: Account Activation 559
11.1 Account Activations Resource 560
11.2 Account Activation Emails 568
11.3 Activating the Account 585
11.4 Email in Production 610
11.5 Conclusion 619
Chapter 12: Password Reset 621
12.1 Password Resets Resource 623
12.2 Password Reset Emails 634
12.3 Resetting the Password 641
12.4 Email in Production (Take 2) 658
12.5 Conclusion 659
12.6 Proof of Expiration Comparison 661
Chapter 13: User Microposts 663
13.1 A Micropost Model 663
13.2 Showing Microposts 679
13.3 Manipulating Microposts 693
13.4 Micropost Images 726
13.5 Conclusion 752
Chapter 14: Following Users 755
14.1 The Relationship Model 756
14.2 A Web Interface for Following Users 774
14.3 The Status Feed 805
14.4 Conclusion 821
Index 825
Michael Hartl created the legendary Ruby on Rails Tutorial that helped jumpstart thousands of web development careers. A cofounder and principal author at Learn Enough, Hartl previously earned a Ph.D. in physics at the California Institute of Technology (Caltech), where he received a Lifetime Achievement Award for Excellence in Teaching. He is also an alumnus of Harvard University and the world-renowned Y Combinator entrepreneur program.
Praise for Michael Hartl's Books and Videos on Ruby on Rails "My
former company (CD Baby) was one of the first to loudly switch to
Ruby on Rails, and then even more loudly switch back to PHP.
(Google me to read about the drama.) This book by Michael Hartl
came so highly recommended that I had to try it, and the Ruby on
RailsTM Tutorial is what I used to switch back to Rails again."
--From the Foreword by Derek Sivers (sivers.org)
Formerly: founder of CD Baby; Currently: founder of Thoughts
Ltd. "I started working on a project but didn't quite understand
some rails concepts. Needed a good tutorial and found lots of
recommendations for @mhartl's rails tutorial . . . and man it's so
good. The hype def matches the product."
--Pratik Tamang, https://twitter.com/codingkrazy "The rails
tutorial by @mhartl is the best web dev resource ever written."
--Daniel Gamboa, Product Manager, Figment "My first programming
book was the Ruby on Rails Tutorial from @mhartl. The best part was
it taught me general skills to be an effective developer."
--Jack Gray, staknine.com "Michael Hartl's Rails Tutorial book is
the #1 (and only, in my opinion) place to start when it comes to
books about learning Rails. . . . It's an amazing piece of work
and, unusually, walks you through building a Rails app from start
to finish with testing. If you want to read just one book and feel
like a Rails master by the end of it, pick the Ruby on RailsTM
Tutorial."
--Peter Cooper, editor, Ruby Inside "Michael Hartl's Ruby on
RailsTM Tutorial seamlessly taught me about not only Ruby on Rails,
but also the underlying Ruby language, HTML, CSS, a bit of
JavaScript, and even some SQL--but most importantly it showed me
how to build a web application (Twitter) in a short amount of
time."
--Mattan Griffel, cofounder & CEO of One Month "Although I'm a
Python/Django developer by trade, I can't stress enough how much
this book has helped me. As an undergraduate, completely detached
from industry, this book showed me how to use version control, how
to write tests, and, most importantly--despite the steep learning
curve for setting up and getting stuff running--how the end result
of perseverance is extremely gratifying. It made me fall in love
with technology all over again. This is the book I direct all my
friends to who want to start learning programming/building stuff.
Thank you, Michael!"
--Prakhar Srivastav, software engineer, Xcite.com, Kuwait "It has
to be the best-written book of its type I've ever seen, and I can't
recommend it enough."
--Daniel Hollands, administrator of Birmingham.IO "For those
wanting to learn Ruby on Rails, Hartl's Ruby on RailsTM Tutorial is
(in my opinion) the best way to do it."
--David Young, software developer and author at deepinthecode.com
"This is a great tutorial for a lot of reasons, because aside from
just teaching Rails, Hartl is also teaching good development
practices."
--Michael Denomy, full-stack web developer "Without a doubt, the
best way I learned Ruby on Rails was by building an actual working
app. I used Michael Hartl's Ruby on RailsTM Tutorial, which showed
me how to get a very basic Twitter-like app up and running from
scratch. I cannot recommend this tutorial enough; getting something
up and going fast was key; it beats memorization by a mile."
--James Fend, serial entrepreneur, JamesFend.com "The book gives
you the theory and practice, while the videos focus on showing you
in person how it's done. Highly recommended combo."
--Antonio Cangiano, software engineer, IBM "The author is clearly
an expert at the Ruby language and the Rails framework, but more
than that, he is a working software engineer who introduces best
practices throughout the text."
--Gregory Charles, principal software developer at Fairway
Technologies
![]() |
Ask a Question About this Product More... |
![]() |