Seven Unusual Ruby Datastores

Admit it: you like the unusual. We all do. Despite constant warnings against premature optimization, an emphasis on "readable code", and the old aphorism, "keep it simple, stupid", we just can't help ourselves. As programmers, we love exploring new things.

In that spirit, let's go on an adventure. In this post, we'll take a look at seven lesser-known ways to store data in the Ruby language.

The Ones We Already Know

Before we get started, we'll set a baseline. What are the ways to store data in Ruby that we use every day? Well, these are the ones that come to mind for me: string, array, hash, CSV, JSON, and the filesystem.

We can skip all of these.

So what are some of the other ways to store data in Ruby? Let's find out.

Struct

What Is It?

A struct is a way of bundling together a group of variables under a single name. If you've done any C programming, you've probably come across structs before.

A struct is similar to a class. At its most basic, it's a group of bundled attributes with accessor methods. You can also define methods that instances of the struct will respond to.

In Ruby, structs inherit from Enumerable, so they come with all kinds of great behavior, like to_a, each, map, and member access with [].

You can define a struct object by setting a constant equal to Struct.new and passing in some default attribute names. From there, you can create any number of instances of the struct, passing in attribute values for that instance.

Read More

Deploying Ghost on Engine Yard

Over the past few years a few new blog systems have been released which aim to bring simplicity back to blogging. One of these is Ghost, which got a huge amount of attention with it's amazingly successful Kickstarter campaign in 2013.

If you wanna move your blog to Ghost or wanna start a new one, carry on reading. Follow these steps and you’ll have a Ghost blog running on Engine Yard in a jiffy.

Clone

Before deploy Ghost, we will fork it on GitHub. This way we can add custom themes and deploy hooks. In case you are not familiar with forking a project, go to the Ghost repository and press the Fork button on the top-right of the page. If you don't have an account yet it'll lead you through the steps of creating one.

You should end up with a new fork in your account. Next, we clone the repository to our local machine to prepare it for deployment via git clone and create a new branch. We’ll use this for deployment specific changes.

git clone git@github.com:bastilian/Ghost.git
cd Ghost

Ghost recommends you use the stable branch rather than master production.

So, let's create a branch based on stable:

git checkout stable
git checkout -b 'deploy'
Read More
Learn about Engine Yard
Try Engine Yard for your Ruby or PHP Apps

Integrating React With Backbone

There are so many JS frameworks! It can get tiring to keep up to date with them all.

But like any developer who writes JavaScript, I try to keep abreast of the trends. I like to tinker with new things, and rebuild TodoMVC as often as possible.

Joking aside, when it comes to choosing frameworks for a project, emerging frameworks just haven't been battle-tested enough for me to recommend to clients in most cases.

But like much of the community, I feel pretty confident in the future of React. It's well documented, makes reasoning about data easy, and it's performant.

Since React only provides the view layer of a client-side MVC application, I still have to find a way to wrap the rest of the application. When it comes to choosing a library that I'm confident in, I still reach for BackboneJS. A company that bets on Backbone won't have trouble finding people who can work on their code base. It's been around for a long time, is unopionated enough to be adaptable to many different situations. And as an added bonus, it plays well with React.

In this post, we'll explore the relationship between Backbone and React, by looking at one way to structure a project that uses them together.

Read More

Ninefold Customers, Welcome to Engine Yard!

Since our founding in 2006, Engine Yard has been a stalwart supporter of Ruby on Rails. Over the years we have supported the Bundler, RVM, JRuby and Merb efforts. We continue to move forward with new initiatives to bring Ruby on Rails to a production container.

Our blood is Ruby Red.

As other vendors have transitioned their businesses away from native Ruby on Rails, we are pleased to welcome those who have been left behind to the Engine Yard community.

Ninefold has announced that they will be no longer be supporting their native hosted Ruby customers. Engine Yard stands ready to provide our industry leading platform, migration assistance, and coached deployments of your application today. Our team of support and service engineers will personally assist you in bringing up your application.

As technologies change and evolve, Engine Yard will continue to support you running your applications your way.

Our primary focus is on your success.

We are dedicated to supporting your most critical apps with a platform and a team of professionals who are the best in the business. With real-time customer satisfaction that is consistently at 98% or better, we back up those words publicly with proven results.

To get started, come over to our Ninefold customer page and join us.

We’re standing by to help.

Understanding Rack Apps and Middleware

For many of us web developers, we work on the highest levels of abstraction when we program. Sometimes it's easy to take things for granted. Especially when we're using Rails.

Have you ever dug into the internals of how the request/response cycle works in Rails? I recently realized that I knew almost nothing about how Rack or middlewares work, so I spent a little time finding out. In this post, I'll share what I learned.

What's Rack?

Did you know that Rails is a Rack app? Sinatra too. What is Rack? I'm glad you asked. Rack is a Ruby package that provides an easy-to-use interface to the Ruby Net::HTTP library.

It's possible to quickly build simple web applications using just Rack.

To get started, all you need is an object that responds to a call method, taking in an environment hash and returning an Array with the HTTP response code, headers, and response body. Once you've written the server code, all you have to do is boot it up with a Ruby server like Rack::Handler::WEBrick, or put it into a config.ru file and run it from the command line with rackup config.ru.

Ok, cool. So what does Rack actually do?

Read More

CHECK OUT OUR CURATED COLLECTIONS

Look through our specially curated posts to get focused, in-depth information on a single topic.