Code from the book Rails 4 in Action