Easy Active Record for Rails Developers (The Book + ArcadeNomad Project Source Code)
$38.00
Minimum price
$38.00
Suggested price

Easy Active Record for Rails Developers

Master Rails Active Record and Have a Blast Doing It!

About the Book

Easy Active Record for Rails Developers is the ultimate guide to mastering building database-driven Rails applications using the powerful Active Record ORM Framework. By loosely following along with the development of a fun, web application for retro arcade aficionados, you’ll learn how to:

  • Understand the importance differences between and implement the belongs_to, has_one, has_many, has_and_belongs_to_many and has_many :through model associations
  • Properly validate, filter and manipulate your application’s model data
  • Manage model schemas using Active Record’s powerful migrations tool
  • Create and integrate complex web forms, including those involving nested models
  • Deftly traverse associations using includes and joins
  • Monitor, debug and optimize your queries
  • Integrate user registration and authentication features using the Devise gem

So far, I’m liking the no fluff, straight to the point approach! - Don Pawlowski, Developer, Designing Interactive

Table of Contents

Easy Active Record for Rails Developers is divided into six chapters covering the fundamental topics most critical to today's Rails developer.

Chapter 1. Introducing Models, Schemas and Migrations

In this opening chapter we'll get acquainted with many of the fundamental Active Record features you'll use throughout your project's lifetime. You'll learn how to create the models used to manage the application's business logic and provide convenient interfaces to the underlying database. You'll also learn how to use a great feature called *migrations* to create and evolve your database schema. The chapter concludes with a section explaining how to begin testing your models with RSpec and factory_girl

Chapter 2. Loading, Validating and Manipulating Data

In this chapter you'll learn how to easily load, or *seed*, your application with an initial data set, as well as create and manipulate data. Of course, because we'll want to eliminate all possibilities of incomplete or invalid data from being persisted to the database, you'll also learn how to enhance your application models using a variety of *validators*. Additionally, we'll build on the introductory model testing material presented in the previous chapter. Notably, you'll learn how to create tests for ensuring you've properly fortified your models with enough validators to ensure unwanted data can't slip through the cracks.

Chapter 3. Querying the Database

In Chapter 2 you learned how to load seed data and create records, now it's time to begin querying that data! In this chapter I'll introduce you to Active Record's array of extraordinarily powerful query features. By the conclusion of this chapter you'll know how to efficiently query for all records, retrieve a specific record according to primary key, select only desired columns, order, group and limit results, retrieve random records, and paginate results. You'll also learn how to integrate these queries with the application controller and view to create listing and detail pages. Always striving towards writing readable code, we'll also enhance the models using a fantastic feature known as a *scope*.

Chapter 4. Introducing Associations

Building and navigating table relations is an standard part of the development process even when working on the most unambitious of projects, yet this task is often painful when working with many web frameworks. Not so with Rails. Thanks to a fantastic feature known as *Active Record Associations*, defining and traversing these associations is a fairly trivial matter. In this chapter I'll show you how to define, manage, and interact with the `belongs_to`, `has_one`, `has_many`, `has_many :through`, and the `has_and_belongs_to_many` associations.

Chapter 5. Mastering Web Forms

Your application's web forms will preferably interact with the models, meaning you'll require a solid grasp on Rails' form generation and processing capabilities in order to integrate with your models in the most efficient way possible. While creating simple forms is fairly straightforward, things can complicated fast when implementing more ambitious solutions such as forms involving multiple models. In this chapter I'll go into extensive detail regarding how you can integrate forms into your Rails applications, covering both Rails' native form building solutions as well as several approaches offered by popular gems.

Chapter 6. Debugging and Optimizing Your Application

While it's fun to brag about all of your project's gloriously cool features, they came at great expense of your time and brainpower. Much of the effort was likely grunt work, spent figuring out problems such as why a query was running particularly slow or the reason a complex association wasn't working as expected. This important but decidedly unglamourous part of programming is something I try to minimize on every occasion by relying on a number of tools and techniques that can automate much of the analysis and debugging process. In this chapter I'll introduce you to several of my favorite solutions for debugging and optimizing Rails applications.

Chapter 7. Integrating User Accounts with Devise

Offering users the opportunity to create an account opens up a whole new world of possibilities in terms of enhanced interactivity and the opportunity to create and view custom content. Yet there are quite a few moving parts associated with integrating even basic account features, including account registration, secure password storage, sign in, sign out and password recovery interfaces, and access restriction. Fortunately the fantastic Devise gem greatly reduces the amount of work otherwise required to implement account creation, authorization and management features, and in this chapter I’ll introduce you to many of the wonderful features this gem has to offer.

Chapter 8. Powerful Active Record Plugins

Ruby on Rails is such a powerful solution thanks in large part to its enormous ecosystem. You're probably familiar with prominent gems such as Devise, RSpec, and FriendlyId, but there are also much more focused gems capable of extending specific parts of Rails, including templating (such as Redcarpet) and e-mail (see the popular Mail gem). So too can you extend Active Record in a variety of interesting and useful ways, and in this chapter I'll introduce you to a few of my favorite gems, including Acts As Taggable On, Decent Exposure, and Geocoder.

  • Share this book

  • Categories

    • Software

About the Author

W. Jason Gilmore
W. Jason Gilmore

W. Jason Gilmore (http://www.wjgilmore.com) is a Columbus, Ohio-based software developer, writer and consultant. He has spent much of the past 15 years helping companies of all sizes build amazing solutions. Recent projects include a Rails-driven e-commerce analytics application for a globally recognized publisher, a Linux-powered autonomous environmental monitoring buoy, and a 10,000+ product online store.

Jason is the author of seven books, including the bestselling "Beginning PHP and MySQL, Fourth Edition", "Easy PHP Websites with the Zend Framework, Second Edition", and "Easy Active Record for Rails Developers". Over the years Jason has published more than 300 articles within popular publications such as Developer.com, JSMag, and Linux Magazine, and instructed hundreds of students in the United States and Europe.

Jason is cofounder of the wildly popular CodeMash Conference, the largest multi-day developer event in the Midwest. Away from the keyboard, you’ll often find Jason hunched over a chess board or having fun with DIY electronics.

Packages

The Book

This package includes the book, and of course all updates are free to existing readers forever!

  • PDF

  • EPUB

  • WEB

  • English

$29.00
Minimum price
$29.00
Suggested price
The Book + ArcadeNomad Project Source Code

This package includes the book in addition to *all* of the source code and sample data used to power the ArcadeNomad demo project.

  • PDF

  • EPUB

  • WEB

  • English

$38.00
Minimum price
$38.00
Suggested price

Table of Contents

  • Introduction
    • Introducing Active Record
    • About this Book
    • Introducing the ArcadeNomad Theme Project
    • About the Author
    • Errata and Suggestions
  • Chapter 1. Introducing Models, Schemas and Migrations
    • Creating the ArcadeNomad Project
    • Installing the RSpec, FactoryGirl and Database Cleaner Gems
    • Introducing Rails Models
    • Rails Models are Plain Old Ruby Objects
    • Introducing Migrations
    • Testing Your Models
    • Conclusion
  • Chapter 2. Loading, Validating and Manipulating Data
    • Seeding and Updating Your Database
    • Callbacks
    • Introducing Rails Validators
    • Creating, Updating, and Deleting Records
    • Deleting and Destroying Records
    • Conclusion
  • Chapter 3. Querying the Database
    • Finding Data
    • Paginating Results
    • Creating a Prettier URL with FriendlyId
    • Introducing Scopes
    • Conclusion
  • Chapter 4. Introducing Associations
    • Normalizing Your Database
    • Introducing Associations
    • Eager Loading of Associations
    • Polymorphic Models
    • Conclusion
  • Chapter 5. Mastering Web Forms
    • Web Form Fundamentals
    • Rails Routing and Forms
    • Creating a Simple Contact Form
    • Managing Your Application Data
    • Useful Forms-Related Gems
    • Conclusion
  • Chapter 6. Debugging and Optimizing Your Application
    • Debugging Your Application
    • Optimizing Your Application
    • Summary
  • Chapter 7. Integrating User Accounts with Devise
    • Installing Devise
    • Creating the User Account Model
    • Adding User Registration Capabilities
    • Adding User Sign In and Sign Out Capabilities
    • Adding User Account Management Capabilities
    • Adding Password Recovery Capabilities
    • Restricting Access to Authenticated Users
    • Commonplace Devise Customizations
    • Conclusion
  • Chapter 8. Powerful Active Record Plugins
    • Tagging Your Content Using the Acts As Taggable On Gem
    • Cleaning Up Your Controllers with the Decent Exposure Gem
    • Geocoding Your Models
    • Summary

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub