How to Install Zsh

Installation

I use Zsh as my default shell. Here I’m going to show how to install and configure it.

To use Zsh I recommend the oh-my-zsh framework to make it easier. The first thing we need to do is install Zsh if we don’t have it already installed...


How to Install Postgresql in Chakra Linux

One of the basic packages we need as developers is a Database Management System (DBMS). The one I use most is Postgresql and here I’m going to show how to install it in Chakra Linux that probably will work on other Arch derived distros. This installation...


Using Vim Regexp to Update to RSpec 3 Syntax

Recently, I had to update a project that uses RSpec. Part of the migration consisted in updating the RSpec syntax from version 2 to version 3. Since I use Vim, I ended up creating a bunch of regular expressions to make those updates. Here I will show...


Directory tree

For my previous post, I had to show my projects’ directory tree. Originally, I had copied and pasted it from my Vim. However, there is a command for that task: tree. I didn’t have it installed so I had to do it. I’m using pacman but you can use yum



Joins vs Includes (Español)

A veces, includes y joins pueden resultar confusos porque hay escenarios donde parecen ser intercambiables, pero hay razones específicas para usar uno o el otro.

joins

joins nos permite especificar una relación a incluirse en la consulta. La consulta...


Joins vs Includes

Sometimes, joins and includes can be confusing because there are scenarios where they seem to be interchangeable, but there are specific reasons to use one or the other.

joins

joins allow us to specify a relation to be included in the query. The...


Minitest v4 y v5

La versión actual de Minitset es 5, ésta es la que obtenemos al ejecutar gem install minitest. Sin embargo, es muy probable que nuestra versión sea la 4, porque es la versión que se incluye con Ruby. Es decir, si no hemos instalado Minitest de manera...


Minitest v4 and v5

The current version of Minitest is 5, this is what we get if you do gem install minitest. However, chances are that our version is 4, because it is the version included in Ruby. I mean, if we didn’t install Minitest explicitly, then we are using the...


Formularios anidados

En ocasiones, tenemos modelos asociados que necesitamos manipular en un único formulario en lugar de tener un formulario por cada uno de ellos. La gema nested_form nos permite crear formularios complejos cuando trabajamos con modelos anidados, su uso...


Cómo solucionar consultas N+1 en Rails

Uno de los problemas de desempeño más comunes en Rails está relacionado con consultas N+1. Afortunadamente, nuestro framework incluye una solución simple para este problema que debemos conocer para evitarnos algunos dolores de cabeza.

Para aquellos...


How to fix N+1 queries in Rails

One of the most commons performance issues in Rails is related to N+1 queries. Fortunately, our framework includes a simple solution for this problem that we must know in order to avoid some headaches.

For those who don’t know, the issue of N+1 queries...


Super in Ruby

In object oriented programming languages, inheritance is a great concept to use. It is not just about code reuse, but about design. However, we can reuse code when using inheritance, but we need to know how it works within our language and how classes...


Guardar modelos asociados en Rails

Como desarrolladores Rails, solemos olvidarnos de la capa de persistencia gracias a que ActiveRecord se encarga de mapear objetos Ruby a tablas de la base de datos y viceversa (a esto se le conoce como Mapeo objeto_relacional). Nosotros trabajamos...


Struct and OpenStruct in Ruby

The Ruby’s Struct and OpenStruct classes are very useful for some tasks. They act like a simple data structure, similar to hash, but they also allow to access their attributes by calling them directly from the object and not only using the brackets...


Matchers de RSpec para métodos booleanos

RSpec incluye una funcionalidad muy práctica al momento de probar métodos que regresan falso o verdadero. Por convención, en Ruby estos métodos terminan con un signo de interrogación que cierra: ?.

Ejemplo:

class Product
  def initialize(price)
 ...

Merge (Español)

Hay una funcionalidad de Rails que yo utilizo bastante pero tengo la impresión de que no es tan difundida como debería. Estoy hablando del metodo merge de ActiveRecord. Posiblemente la razón por la que no es muy utilizado es que existe un metodo con...


Merge

Rails has a functionality that I use a lot but I think it is not as widespread as it should. I’m talking about the ActiveRecord’s merge method. Probably, the reason why this method is not widely used is because there is a method with the same name...