In Ruby, you have a choice: define classes or modules either inline or nested within another module. While both approaches achieve similar results, there are key functional differences to consider, making nesting the preferred approach. The Subtle Distinction in Referencing Let’s look at an example using User and Admin::User classes: module Admin class Nested #…
Tag: tips
SPA without touching Javascript – The magic of Ruby on rails and Hotwire
It’s been a while since I wrote the last post here, so I decided to write something fun and maybe a good sample for anyone that is learning rails or is a little outdated. The idea here is to write a simple CRUD from scratch, I’ll use a Grid layout to keep everything in the…
I see Dead Jobs everywhere (sidekiq DeadSet)
When you are using Sidekiq to handle asynchronous jobs, some times there are exceptions and jobs failing, and I say sometimes because your environment is probably perfect, there is no lag, all services your jobs depend on are always on and responsive, and you probably write better code than most other developers 😛 otherwise it…
How to create a request scope for your rails application
Some time ago I missed one of the cool features from the time I worked with JavaEE, that was a request scope for some variables.
I know the instance variables on controllers do a great job simulating it, but I needed to access context in a completely different part of the application, that wasn’t always called from controllers, variables that should be scoped to that request.
So I thought, I could create something like that for my rails app.
6 Sidekiq tips and tricks for performance, mantainability and happiness!
This is a very opinionated post, with some performance tips from someone that uses sidekiq for more than two years now, as as such I have already did some mistakes and learnt some tricks. My current opinion is that sidekiq is the best backend job engine for ruby/rails applications. And of course to use it…
Are you tired of typing always the same things on Rails console? what if you don’t need anymore?
After you spend some time working in the same Rails project, being this project whatever project you are working for some time now, you probably use the Rails console a lot, many reasons: Testing code Seting up data Using “binding.pry” to “debug” some controller or model Put whatever you are doing in “rails c” now…
Learn how to make your Rails logs smarter with log_tags!
When you look at the logs of your application in development, they may appear clear and concise to you (probably not thou), but when you are looking at the production logs and there are many simultaneous requests, sometimes it is difficult to know exactly what like of the log is the next entry, or what…
3 common problems of rails application deployments (or any platform really, these problems happens to everyone)
Rails is a really cool framework to work with, but it is not fall proof, and it will not prevent you from doing stupid things, having that said, even with the best tools available, putting a new software in production, or doing a significant upgrade to a software that is already in production is always…