Rails lets us focus on the hard stuff

I went to tour a local chocolate factory, and things did not go as planned. The place was hopping, all of the walk-in spots on the tour were taken, and they didn’t take reservations in advance. My disappointment was lifted by free samples and a nearby brewery, but I remember someone at the factory saying, “There has to be a better way.”

Inspired to create something that would help them, I e-mailed the factory. Two weeks later, I had built a reservations platform in Rails 5, and they were using it.

Rails lets developers focus on the hard stuff. Few other frameworks would let me completely focus on business needs and get something out so quickly.

What’s the hard stuff?

Here’s what shouldn’t be hard when first building an application:

  • Accounting for low-bandwidth connections
  • Supporting a wide array of browsers
  • Implementing a test framework and writing tests
  • Choosing and configuring build tools
  • Setting up a database
  • Setting up hosting
  • Adding basic security (CSRF protection, user authentication)
  • Making big decisions about JavaScript – choosing an MVC, for instance

Here’s what should be hard:

  • Creating a great user experience
  • Making sure the features make sense for the intended customers
  • Defining a data model that makes sense
  • Writing maintainable code

Working on an app on nights and weekends taught me the value of focusing on what should be hard and letting Rails handle the rest.

CSRF protection? Stick to Rails conventions. Testing? Use RSpec, a de-facto Rails community default. User auth? Add a gem like Devise. Build tools? Use built-in Sprockets. Hosting? It’s a breeze with Heroku and Rails 5. Accounting for low-bandwidth connections? Try Turbolinks (more on this below).

Staying focused on business needs, and letting Rails handle the rest, was the only way to ship.

Rails’ nice surprises

I was overseas recently and the internet sucked. Many web sites didn’t load at all. Some would show a layout but no text; others would show a nav bar and nothing else.

My reservation platform loaded quickly. Navigating the app was zippy.

How was this possible? Believe it or not, the improved Turbolinks. Avoiding full-page reload more than halves load time on bad connections. It took no effort on my part; it’s a Rails default.

A time and a place

A couple of years ago, I implemented React at Cook Smarts, a meal planning app. It transformed our JavaScript from spaghetti to well-structured, understandable code with fewer bugs.

Nonetheless, most of Cook Smarts remained vanilla Rails, views and all. We used React surgically, only when a very high level of interactivity was necessary.

Why stick with vanilla Rails? To keep the focus on what should be hard, building new features, rather than restructuring our app to JavaScript MVC with questionable benefits for users.

Frameworks like Rails get this. Next time you build an app, consider a framework that keeps your focus on what should be hard.