How CSRF Tokens work in Ruby on Rails?

Category: Ruby :: Published at: 16.12.2024

All modern frameworks offer protection against CSRF attacks, so these attacks are not as common anymore.
However, this does not mean we don't need to understand what they are and how to protect ourselves from them.

In this article, I will explain what a Rails engineer needs to know about CSRF.

Read more

How to reinstall MySQL on MacOS ARM M1 (and not only)

Category: Ruby :: Published at: 09.12.2024

If you have any issue with MySQL and you want to completely reinstall it on your machine.

This is a quick guide, how to do it:

Read more

How to easily connect your docker container with a postgres on EC2 instance

Category: Ruby :: Published at: 11.10.2024

Let's say, you have a Rails app packed inside docker container. You also have a pg server installed directly on your virtual machine (well, just to save your money). This can be a problem, because on production you should allow only specific ips to have a connection to your database.

How you can do it then? This is a tutorial.

Read more

How to renew SSL certificates with Certbot

Category: Ruby :: Published at: 29.09.2024

If you are using Amazon Linux 2 and want to install SSL Certificate for your domains, certbot is a right call.

This is how you can do it, and also additional info about how you can renew existing certificate

Read more

The role of foreign keys in SQL database

Category: Ruby :: Published at: 31.05.2023

5 rules, why we use Foreign Keys in our databases:

 

  1. Relationships establishment - we can create relations between tables, and even inner join relation within one table between two records
  2. Data Integrity - for example, you can create an order with client_id for client which does not exist in the database
  3. Data consistency and accuracy - when foreign key is defined, it restricts the values that can be inserted or updated in the referencing column
  4. Data querying - thanks to the foreign keys we can retrieve data from multiple tables faster and easier
  5. Data maintenance - it helps cascading updates and deletions, preventing locks mechanisms


Run one spec multiple times

Category: Ruby :: Published at: 22.05.2023

Simple code to run one spec multiple times:

for i in `seq 10`; do rspec spec; done