Home » Ruby » Page 9

Ruby

Producing Documentation for Your Rails API

Why is it such a joy to work with Stripe or Shopify as a developer? It could be for a number of reasons, but one of them is surely that they have great documentation. For these companies, documentation isn’t an afterthought — it’s something you can tell that they obviously spend a lot of time and resources on. Why is ...

Read More »

A Deep Dive into Ruby Scopes

The Ruby language was designed with a pure object-oriented approach. In Ruby, everything is an object. Object-oriented design provides encapsulation for properties and actions. Encapsulation’s purpose is to protect methods and data from outside interference and misuse. With encapsulation, everything has certain scopes from which they may be utilized. Several categories of scope in Ruby are global, instance, and local ...

Read More »

The Simple Yet Powerful Ruby Enumerable Module

Here is a simple requirement: Find the positive numbers in an array. There are most likely hundreds of solutions, but here is one of them: positives = [] for i in [-5, 10, 0, 15, -2] positives << i if i.positive? end p positives # => [10, 15] It works, it’s simple, but it feels clunky (and very un-Ruby like ...

Read More »

Surrogate WebSockets Alongside Rails

ActionCable is coming to Rails 5 and brings with it the promise of using WebSockets directly in Rails. Ruby has a notoriously bad concurrency story, and that certainly extends into the realm of WebSockets and pubsub. ActionCable may be suitable for a small number of authenticated sessions, but scaling persistent connections to thousands or tens-of-thousands won’t be easy. That’s all ...

Read More »

An Introduction to APIs with Phoenix

Phoenix is taking the internet by storm, with good reason. It’s productive, fault-tolerant, concurrent, safe as a compiled language, and blazing fast. It shares many of Rails’ core values, such as convention over configuration, restful resources, and a focus on developer happiness. The cherry on the top: Phoenix was designed from the ground up for WebSockets connections — so you ...

Read More »

Comparing Rails and Phoenix: Part II

In the first post of this two-part series, we touched on generating a new application and talked about the entry point to each application: the Router. We also discussed at a high level about how Phoenix apps can fit into larger OTP applications. In this post, we will be looking at the Model, View, and Controller, the parts that comprise ...

Read More »

Comparing Rails and Phoenix: Part I

As I was thinking about this article a few weeks ago, I was excited when I saw that Chris McCord, creator of the Phoenix Framework in Elixir, was on the Elixir Fountain podcast. One of the things they mentioned on the show was that they were tired of the comparison being made between Rails and Phoenix. The bias of coming ...

Read More »

Do You Believe in Programming Magic?

Unlike pulling a rabbit out of a hat, “magic” in programming is often performed under the guise of productivity. In this post, we’ll look at what defines a magical programming experience for better or worse. If you were in Rails around 2007 you might be quick to describe it as “auto-magical,” and this was a good thing. Magic meant freedom ...

Read More »

How to Build Rails APIs Following the json:api Spec

We’ve talked before about how to build a JSON API with Rails 5. We also discussed using Rails 5 in --api mode, serializing our JSON responses, caching, and also rate limiting/throttling. These are all important topics, but even more important is producing a clear, standards-compliant API. We’re going to look at how to build an API that conforms to the ...

Read More »