This article will guide you through the thought process behind creating a picture_tag helper in Rails.
We implemented this helper to optimize how we serve images on our website and improve performance for SEO.
The result will be close to this:
<picture> <source srcset=”path_to_image.webp” > <img src=”path_to_image.png’” alt=”alt text” ></picture>
Above, you could envision as many sources as you wanted for different formats (or for additional sizes).
The thought process
When I start to implement something in rails, I almost always have the same internal debate:
All coding is fundamentally made of magic and leaps of faith.
It might be because I grew up with very close ties to the worlds created by Ursula K. Le Guin, JRR Tolkien, or JK Rowling. But I have always dreamt of being a wizard, a mage, or whatever term you want to give it.
And I believe the closest we can be to an actual wizard in the real world is coding. after all :
Any sufficiently advanced technology is indistinguishable from magic — Arthur C. Clarke’s third law.
Coding affects the real world and brings forth wonders that…
Over the last couple of weeks, I have been trying to get the basics of go in my free time. To do so, I decided to build a terminal-based Pomodoro timer. If you are not familiar with the Pomodoro technique, here you can find more about it.
I shall not go into too much of the code, but some snippets will feature in…
As a manager, having regularly scheduled times to speak one on one with your team members about non-work-related things can benefit the manager, the team member, and the team considerably.
This thought has not occurred to me alone, and there are probably many sources. In my head, I trace it to a podcast where the interviewee mentioned it. If someone knows the podcast I am talking about; please reach out. I want to read the interviewee’s book.
All this to say, the idea of a regular one-on-one meeting with my teammates stuck with me, and after six monthly one-on-one, I…
In this article, we will learn how to code a reactive navbar using rails.
If you want to follow along, here is the point in time where I start writing this article: https://github.com/pablocm90/learning-port/tree/pre-navbar.
To do so, we want to imagine at least roughly how our navbar should look like when seeing it from a computer and a tablet, or phone.
Then we will code the style for four pre-determined breakpoints.
Finally, we will add some interactivity.
When sketching the first pass of an element, especially for a personal project, I like to do it with pencil and paper.
A couple of days ago, I had to create a suggestion system using, among other things, a full-text search.
I quickly came across pg_search. And let me tell you, people: this gem is crazy good. It will allow you out of the box to do a full-text search against several columns or even associations. (You can also run the search against all your models).
I won’t tell you all the functionalities, but I can tell you there are enough of them for most usages. It reproduces quite closely what PostgreSQL allows in terms of full-text search
It does need some…
I love learning and my latest learning project includes documenting what I do, making it public might make someone enjoy the adventure with me or even learn a little thing here or there :)
Check it out at the repository I created to host my experiments (soon to be a website)
I am reasonably sure that the stack will evolve since I will want to experiment and learn other languages as I progress, but in my case, I knew that I would start with a Rails Back End.
CTO of Study Advisor, learned how to code at Le Wagon. I love coding and plan to keep learning as much as I can of this wonderful world.