Nested Single Table Inheritance doesn’t work well. Here’s what you must know to make it work or work around it.
I recently stumbled across the following scenario.
Initial specifications: a project owner creates a project and donors can contribute any amount of money to that project.
Later, a little change was made to the specifications: a donor may either be a natural person (an individual human) or a legal person (a corporation or any other kind of legal entity).
Since both are donors and will share some significant amount of logic, it seems obvious that they are both a specialization of
I’ll end up this article with a step-by-step section explaining how to add Bootstrap 4 and FontAwesome 5 to a Rails 6 project.
Oftentimes we need contextual validation in ActiveRecord models and find no ideal way of doing so. This article exposes an elegant, lightweight, dependency-free solution.
First, let’s have in mind two case studies that perfectly illustrate this matter:
What tools ActiveRecord provides to deal with this?
This blog post is for backend developers who want to learn the basics of technical SEO.
As a backend developer, my focus mostly goes to implementing new features, fixing bugs, optimizing SQL queries and so forth. What about SEO, though? Well, I’ve never learned that. It is a whole different skill set, a job on its own. Out of curiosity, and because I had the opportunity to build a super tiny one page static website, I took some time to learn about the basics of SEO. Bear in mind I’m not laying down advanced strategies, this is more like bullet points to make sure you’re not shooting yourself in the foot. …
Have you ever wondered how your Rails application boots? I mean, when you execute
rails server, what happens?
To answer this question, we’re going to start by generating a new Rails 6 application (I’m currently running 6.0.0.rc1).
$ rails new iluvrails
$ cd iluvrails
The starting point of the boot sequence is the rails executable. To simplify this blog, we’ll start our journey in
By the way, what is the rails gem? It’s a packaging for all the following:
$ gem dependency rails -v 6.0.0.rc1
actioncable (= 6.0.0.rc1)
actionmailbox (= 6.0.0.rc1)
actionmailer (= 6.0.0.rc1)
actionpack (= 6.0.0.rc1)
actiontext (= 6.0.0.rc1)
actionview (= 6.0.0.rc1)
activejob (= 6.0.0.rc1)
activemodel (= 6.0.0.rc1)
activerecord (= 6.0.0.rc1)
activestorage (= 6.0.0.rc1)
activesupport (= 6.0.0.rc1)
bundler (>= 1.3.0)
railties (= 6.0.0.rc1) …
Once upon a time, there was a Rails developer who wanted to become a Rails contributor. Deep down he even wanted to become a Rails core team member! So one day he decided to take a first step: he downloaded the source code of Ruby on Rails!
So I downloaded the source code of Rails:
$ git clone email@example.com:rails/rails.git
$ cd rails
Damn.. so much stuff in here.. I know most of Rails components, but there are some novelties in here as well. Thankfully Rails has several guides to help me fill the gaps. …
Ruby on Rails, our beloved framework, provides a new standard for file upload. Please welcome ActiveStorage!
This article is a super quick, straight to the point guide to get started with ActiveStorage.
I’ve hosted a working example application on Github for you to try it out-of-the-box. It illustrates most of what this article presents. The link is at the end of the article.
Table of content:
La productivité, c’est le saint Graal. Le problème, c’est que l’on a faux sur toute la ligne.
La génération des baby-boomers (nés entre 1945 et 1960) a connu une approche industrielle de la productivité. Comme à l’usine, on leur a expliqué qu’être productif c’est faire plus en toujours moins de temps. Et comme des machines que l’on ferait tourner quelques heures de plus pour fabriquer un peu plus, les salariés devaient également faire des journées plus longues pour produire un peu plus.
Notre génération a vu la notion de productivité évoluer. Aujourd’hui, nous baignons dans un univers très inspiré des startups où il faut faire des to-do lists et du Pomodoro, autrement dit mettre en œuvre des techniques d’organisation. L’accent n’est plus mis sur la durée de travail (maintenant acquise) mais sur l’utilisation d’outils et techniques censés décupler notre rendement. …
This is a practical guide to start using StimulusJS in a Ruby on Rails project (with a bonus at the end 😉). You’ll also find at the end of the article a link to a project that uses all that’s presented in this article for you to try it out of the box.
You might be tempted to compare it to other frameworks such as ReactJS, Angular or VueJS but you should not. StimulusJS doesn’t play in their field since it doesn’t intend to build user interface components, synchronize frontend and backend using AJAX or any of this stuff. …
Working on a new project, I finally had the opportunity to try Rails 5.2 new way of handling encrypted credentials.
So far we’ve been used to:
Rails now ships with a new standard for storing credentials, so let's have a look at it.
The first thing to notice is that Rails 5.2 projects come with two new files:
config/credentials.yml.enc: encrypted yaml storage (your secret values are stored here)
config/master.key: encryption key
credentials.yml.enc is encrypted with the secret key that's stored in
master.key is ignored in
.gitignore and should not appear anywhere in your git repository. We'll talk later about how this encryption key should be stored and used on your production server(s). …