Understanding Threads and Processes in Ruby

In Ruby, threads and processes are essential concepts for concurrent programming, allowing you to execute multiple tasks concurrently. Let’s delve into these concepts, the GVL, Ruby 3.x options like Ractors and the fiber scheduler, and how to size Puma workers and threads.

 ·  · 9 min · 1845 words · Bá Tới

Understanding Access Control in Rails: Private, Protected, and Public

Access control decides which methods of a class can be called from outside it. Ruby (and therefore every Rails app) provides three access control levels: private, protected, and public. Let’s explore each of these levels, how they really behave, and their implications in Rails development.

 ·  · 4 min · 777 words · Bá Tới

Preparing for a Ruby on Rails Web Development Interview

Preparing for a Ruby on Rails web development interview requires a solid understanding of web development concepts, Ruby programming language, and the Rails framework. Here’s a list of common interview questions that cover various aspects of web development and Ruby on Rails, including Rails 7 and Rails 8 topics.

 ·  · 16 min · 3248 words · Bá Tới

Understanding Sidekiq: A Powerful Background Job Processing Solution

In today’s web development landscape, handling background job processing efficiently has become crucial for building robust and scalable applications. Sidekiq stands out as a popular choice among developers due to its simplicity, performance, and powerful features. This article covers how it works, how to set it up in Rails, and how to tune it.

 ·  · 7 min · 1443 words · Bá Tới

Understanding CSRF in Ruby on Rails

CSRF (Cross-Site Request Forgery) is a type of attack where an attacker tricks a user into performing unintended actions on a web application in which the user is authenticated. This article explains what CSRF is, how Rails’ authenticity tokens, Origin check and SameSite cookies protect against it, and when it is safe to skip the check.

 ·  · 5 min · 1030 words · Bá Tới

Ruby on Rails Best Practices

In Ruby on Rails, following best practices is essential for writing clean, maintainable, and efficient code. By adhering to established conventions and guidelines, developers can optimize their codebase, improve performance, and enhance the overall quality of their Rails applications. Let’s explore some of the best practices for Ruby on Rails development.

 ·  · 8 min · 1492 words · Bá Tới

Prevent Content Type Spoofing on Paperclip

If you have ever used paperclip, maybe you have seen the message like that: Image has contents that are not what they are reported to be. For this bug, we will have two solutions: specify an extension that cannot otherwise be mapped or override media_type_spoof_detector method.

 ·  · 2 min · 265 words · Bá Tới

Ruby Best Practices

In Ruby, following best practices is essential for writing clean, maintainable, and efficient code. By adhering to established conventions and guidelines, developers can optimize their codebase, improve performance, and enhance the overall quality of their Ruby applications. Let’s explore some of the best practices for Ruby development.

 ·  · 5 min · 896 words · Bá Tới

Proc, Lambda, and Block in Ruby

In Ruby, you can invoke, execute, or run Threads, Anonymous functions, Strings, and even methods that have been turned into objects. Let’s delve into the Callable and Runnable nature of Objects in Ruby.

 ·  · 5 min · 903 words · Bá Tới