JSONb with Ruby on Rails

I needed to get something from the database in my job. I tried the current query using PSequel and it gave an error. SELECT * FROM declarations WHERE data->>’some_data’ IS NOT NULL; The way I got the results was through the console with the following: bundle exec rails console declarations_ids = [] Declaration.find_each do |d| […]

Read More JSONb with Ruby on Rails

find in Ruby

So, I was working and found this nice idea on the code base about using the find for mail dunnings. This will be simplified to the max in order to keep the post short. In the Payments table we have the following columns: payment_reminder_sent_at first_dunning_sent_at last_dunning_sent_at What this code do is, find in the current […]

Read More find in Ruby

Holidays helper in Ruby on Rails

Today, while doing a calendar I found a module on Rails called Holidays. I will use the Rails console to demonstrate: bundle exec rails c Loading development environment (Rails 5.0.1) [1] pry(main)> Holidays.on(Date.tomorrow, :pt) => [{:date=>Wed, 01 Nov 2017, :name=>”Dia de Todos-os-Santos”, :regions=>[:pt]}] [2] pry(main)> Holidays.on(Date.today, :pt) => []

Read More Holidays helper in Ruby on Rails

The importance of a Backup

Before I started working professionally as a software engineer, I would see a lot of people talking about the importance of backups in the IT industry. A few weeks ago I worked on a project that didn’t have any backups and was in production! The first thing I did was a backup and used the […]

Read More The importance of a Backup

Ruby cover? instead of include?

Last week I learned that we should use cover? instead of include?. When you ask a range if it includes something, ruby is going to instantiate every object within that range and then check if the object you pass into include? exists in there. If you ask cover? it’s just going to figure out and […]

Read More Ruby cover? instead of include?

Taking more than you can handle

Some time ago a friend gave me a coding challenge which I decided to make it in Ruby on Rails, I hesitated because was expecting that an Enterprise would give me a task to build something in JavaScript/HTML/CSS, so the time passed. Then I applied for a company that is hiring any kind of developer […]

Read More Taking more than you can handle