Jump Start Sinatra – With this book and a little Ruby, you can make Sinatra sing – #programming #bookreview

Jump Start Sinatra
Get Up to Speed with Sinatra in a Weekend
Darren Jones
(SitePoint – Kindle, Paperback)

Many Ruby developers love Rails for its power and capabilities as a model-view-controller (MVC) framework. But some of them don’t like Rails’ size, complexity, and learning curve.

Meanwhile, many other Rubyists love Sinatra for its simplicity and ease of learning, plus its ability “to create a fully functional web app in just one file,” says Darren Jones in his new book, Jump Start Sinatra. “There are no complicated setup procedures or configuration to worry about. You can just open up a text editor and get started with minimal effort, leaving you to focus on the needs of your application.”

Jones does not temper his enthusiasm for Sinatra, adding that “there isn’t a single line of bloat anywhere in its source code, which weighs in at fewer than 2,000 lines!”

His 150-page book covers a lot of ground, from downloading and installing Sinatra to building websites, working with SQLite, Heroku, Rack, jQuery, and Git, and even using some CoffeeScript (to avoid “getting our hands dirty writing JavaScript…”). He also shows how to create modular Sinatra applications that use separate classes.

“Sinatra makes it easy–trivial almost–to build sites, services, and web apps using Ruby,” the author states. “A Sinatra application is basically made up of one or more Ruby files. You don’t need to be an expert Rubyist to use Sinatra, but the more Ruby you know, the better you’ll be at building Sinatra apps.”

Jones adds: “Unlike Ruby on Rails, Sinatra is definitely not a framework. It’s without conventions and imposes no file structure on you whatsoever. Sinatra apps are basically just Ruby programs; what Sinatra does is connect them to the Web. Rather than hide behind lots of magic, it exposes the way the Web works by making the key concepts of HTTP verbs and URLs an explicit part of it.”

Jump Start Sinatra is a well-written, appropriately illustrated guide to getting started with this popular free software. Ruby newcomers may wish for a few more how-to steps or code examples. But the counter argument is, if you’re brand-new to Ruby, save Sinatra for later; focus on getting learning Ruby first. 

Darren Jones does not buy into a common assessment that’s often heard when developers are asked their views of Rails vs. Sinatra. “Opinions abound that Sinatra can only be used for small applications or simple APIs, but this simply isn’t true,” he argues. “”While it is a perfect fit for these tasks, Sinatra also scales impressively, demonstrated by the fact that it’s been used to power some big production sites.”

Some of those “big production sites,” according to Wikipedia, include such notables as Apple, LinkedIn, the BBC, the British government, Heroku, and GitHub.

Si Dunn

Deploying Rails – A good how-to guide covering choices, tools & best practices – #programming #bookreview

Deploying Rails: Automate, Deploy, Scale, Maintain, and Sleep at Night
Anthony Burns and Tom Copeland (Pragmatic Bookshelf, paperback)

Maybe you have been studying Ruby and Rails and now feel ready for the next big step. Perhaps you are already on a job where a Rails application needs to be deployed and running on a server ASAP. Or, maybe you manage a team that must deploy and support a Rails app, and you want to understand more of what they actually must accomplish to get the app up and running – and keep it running.

Deploying Rails is a very good guide to the decisions that must be made and to the tools and best practices essential for success. The two writers are both professional Rails developers with strong backgrounds.

Their 217-page book, they note, “is “centered around an example social networking application called MassiveApp. While MassiveApp may not have taken the world by storm just yet, we’re confident that it’s going to be a winner, and we want to build a great environment in which MassiveApp can grow and flourish. This book will take us through that journey.”

That “journey” is organized into 10 chapters and two appendices, all well written and illustrated with code examples.

  • Chapter 1: Introduction – (including choosing a hosting location)
  • Chapter 2: Getting Started with Vagrant – (setting up and managing a virtual server and virtual machines)
  • Chapter 3: Rails on Puppet – (“arguably the most popular open source server provisioning tool.…”)
  • Chapter 4: Basic Capistrano – (“the premier Rails deployment utility….”)
  • Chapter 5: Advanced Capistrano – (deals with making deployments faster and also easier when “deploying to multiple environments.”)
  • Chapter 6: Monitoring with Naigos – (monitoring principles and how to apply them to Rails apps. Also, how to perform several types of checks.)
  • Chapter 7: Collecting Metrics with Ganglia – (how to gather a Rails app’s important metrics from an infrastructure level and an application level.)
  • Chapter 8: Maintaining the Application – (how to handle “the ongoing care and feeding of a production Rails application.”)
  • Chapter 9: Running Rubies with RVM – (using the Ruby enVironmental Manager [RVM] in development and deployment.)
  • Chapter 10: Special Topics – (“We’ll sweep through the Rails technology stack starting at the application level and proceed downward to the operating system, hitting on various interesting ideas as we go.”)

The two appendices cover (1) “a line-by-line review of a Capistrano deployment file” and (2) “deploying MassiveApp to an alternative technology stack consisting of nginx and Unicorn.”

A key focus of the book is building a set of configuration files and keeping the latest versions stored in Git, so deployment of a new or updated app can go smoother.

Deploying a Rails app involves making many different choices, and the process can go wrong quite easily if not set up properly.

“The most elegant Rails application,” the authors caution, “can be crippled by runtime environment issues that make adding new servers an adventure, unexpected downtime a regularity, scaling a difficult task, and frustration a constant.

“Good tools do exist for deploying, running, monitoring, and measuring Rails applications, but pulling them together into a coherent whole is no small effort.”

Deploying Rails can significantly ease the complicated process of getting a new Rails application running on a server. Equally important, Rails experts Anthony Burns and Tom Copeland can show you how to keep the app running smoothly and configured for growth as it gains users, functionality, and popularity.

Si Dunn

Learning Rails 3 – It’s not easy, but this good how-to guide definitely can help – #bookreview

Learning Rails 3
Simon St.Laurent, Edd Dumbill, and Eric J. Gruber
(O’Reilly,
paperbackKindle)

Ruby on Rails frequently is hailed as an “outstanding” or “powerful” or “amazing” tool for creating web applications.

But beginners often dive into it, quickly go off the rails, and give up in frustration.

“Building a Ruby on Rails application requires mastering a complicated set of skills,” the authors of Learning Rails 3 concede. Indeed, you may encounter several “problems and confusions” just getting everything installed, configured and running the right way.

Fortunately, Learning Rails 3 shows how to make the installation, configuration, and initial testing go fairly smoothly. I didn’t know (or understand) Rails and had only a smattering of Ruby experience. But I was able to accomplish an easy installation on a Windows XP machine, using railsinstaller.org. Then I was able to follow the instructions in Learning Rails 3 and get it all running.

Caution: Read and follow the book’s steps very carefully, in the correct order. Pay close attention to the text and code examples. At several different points, I glanced past a step or skipped an important character as I typed. And, no surprise, I ran into puzzling error messages or code failures until I backtracked and figured out what I had skipped. Also, a lot of stuff happens or appears to happen when you create a new Rails application or do some other tasks. Long lists of status notifications, warnings, and miscellaneous cryptic messages will stream by. But don’t panic.

“The only mandatory technical prerequisite for reading this book is direct familiarity with HTML and a general sense of how programming works,” the authors emphasize. “You’ll be inserting Ruby code into that HTML as a first step toward writing Ruby code directly, so understanding HTML is a key foundation.”

Once you get past the initial shock of installing Ruby on Rails, working at the command line, and modifying some bits of code deep within a few subdirectories, you will start discovering the power and possibilities of Rails.

If you’ve never worked with Ruby, the authors offer, in Appendix A, “An Incredibly Brief Introduction to Ruby.” (Appendix B is “An Incredibly Brief Introduction to Relational Databases,” and Appendix C provides “An Incredibly Brief Guide to Regular Expressions.”) You won’t need to be a Ruby expert; just have some basic knowledge of how to work it.

The remainder of the 387-page book is organized into 20 chapters:

  1. Starting Up Ruby on Rails
  2. Rails on the Web
  3. Adding Web Style
  4. Managing Data Flow: Controllers and Models
  5. Accelerating Development with Scaffolding and REST
  6. Presenting Models with Forms
  7. Strengthening Models with Validation
  8. Improving Forms
  9. Developing Model Relationships
  10. Managing Databases with Migrations
  11. Debugging
  12. Testing
  13. Sessions and Cookies
  14. Users and Authentication
  15. Routing
  16. From CSS to SASS
  17. Managing Assets and Bundles
  18. Sending Code to the Browser: JavaScript and CoffeeScript
  19. Mail in Rails
  20. Pushing Further into Rails

The book mercifully does not dump you head-first into the middle of Model-View-Controller (MVC) architecture. You begin by gently nibbling at its edges and using a few things you likely already know. Once you feel comfortable and can find your way around some of the subdirectories, then the real fun begins. The authors offer a rich array of how-to discussions, code examples, screen shots and “Test Your Knowledge” quizzes (with the answers conveniently available).

Learning Rails 3 is an excellent guide for Ruby on Rails newcomers. And those already working with Rails can learn from it, too.

Si Dunn