ruby

Optimize Database Performance in Ruby on Rails and ActiveRecord

Optimize Database Performance in Ruby on Rails and ActiveRecord

In Rails, we're more likely to use SQL databases than other frameworks. Unlike NoSQL databases, which can be scaled horizontally with relative ease, SQL databases like PostgreSQL or MySQL are much less amenable to easy scaling. As a result, our database usually becomes the primary bottleneck as our business grows. Although SQL databases are very efficient, as our growing customer base puts an increasing load on our servers, we begin scaling our instance counts, workers, etc. But we can't just make copies of our database for each new server we spin up. This makes optimizing database performance critical for any…
Read More
Ruby exception Handling Pitfall: Understanding Rescue Clause Hierarchy

Ruby exception Handling Pitfall: Understanding Rescue Clause Hierarchy

Context Let's consider the following code, defining basic classes and one custom error: class CustomError < StandardError; end class Parent def raise_custom_error raise CustomError rescue StandardError puts "StandardError rescued" end end class Child < Parent def call raise_custom_error rescue CustomError puts "CustomError rescued" end end Enter fullscreen mode Exit fullscreen mode Now, let's examine the following method call:: Child.new.call Enter fullscreen mode Exit fullscreen mode To summarize, this code does the following: Defines a CustomError class that inherits from StandardError Creates a Child class with a #call method that invokes raise_custom_error from its parent class Parent Implements exception handling in…
Read More
Streamlining Your Rails 8 App: Migrating from Postgres to SQLite

Streamlining Your Rails 8 App: Migrating from Postgres to SQLite

Originally published on my blog: Streamlining Your Rails 8 App: Migrating from Postgres to SQLite With Rails 8's shift to SQLite as the new default database, developers now have the opportunity to simplify their application stack while retaining power and flexibility. Whether you are running a small personal project or scaling up, SQLite's improvements make it a great option for production use. After all SQLite, which was initially released in 2004, has come a long way and is now a powerful, reliable, and performant database engine – perfect for many applications. With the Rails 8 release, SQLite has become the…
Read More
How to Build a Twitter Clone with Rails 8 and Turbo 8

How to Build a Twitter Clone with Rails 8 and Turbo 8

Hotwire, StimulusJS, and Turbo have been out for the better part of half a decade, and there have been sweeping changes in the Turbo Broadcast and Stream patterns this past year. All of this gets bundled with Rails 8, plus other new features to make development even quicker, such as SolidQueue, SolidCache, and SolidCable. Two of those three make it dead simple to get this clone up and running super quick! Note: I use Bootstrap when making something quick. You can throw an asset tag in the views/layout/application.html.erb or add Bootstrap to the rails --new command (but have yarn installed…
Read More
How the Ruby Repository Masters Fast Merges: Cutting Corners or Genius Efficiency?

How the Ruby Repository Masters Fast Merges: Cutting Corners or Genius Efficiency?

Introduction: The Ruby Repository's Stellar Track Record The "Ruby" repository is a pivotal project in the Ruby programming language community. It's a hotbed for innovation and collaboration, attracting a diverse group of contributors. But what truly sets this repository apart is how it manages to consistently keep its merge times impressively low, despite the high volume of contributions. This case study examines what the Ruby repository does right, particularly focusing on its fast merge times, and analyzes the broader implications of this efficiency on both the project and the community. Analyzing Ruby's Efficiency and Pitfalls with Middleware Dora Metrics If…
Read More
Python and Ruby Development Tools: A Quick Reference

Python and Ruby Development Tools: A Quick Reference

Purpose Python Tool Ruby Tool Use Case Python Installation Method Ruby Installation Method Package Manager pip gem Installing packages pip install <package> gem install <gem_name> Dependency Management pipenv, poetry bundler Managing dependencies pip install pipenv / pip install poetry bundle install Environment venv, Conda rbenv, RVM, chruby Isolating project environments python -m venv <env_name> / conda create -n <env_name> rbenv install <version> / rvm install <version> Version Management pyenv, Conda rbenv, RVM, chruby Managing Python/Ruby versions pyenv install <version> / conda install python=<version> rbenv install <version> / rvm install <version> Combined (Version + Environment) pyenv-virtualenv RVM Version + env management…
Read More
Reminder about Friendly.rb – one month to the conference

Reminder about Friendly.rb – one month to the conference

Your friendly reminder about Friendly.rb - there is almost 1 month until the conference. I am enthusiastic about moderating a panel about #Ruby at Scale. All four guests have great stories to share about scaling Ruby in various settings and configurations. We plan to talk about Ruby and Rails at scale from performance, team and developer experience perspective. My focus will be on extracting concrete examples and advice for anyone starting a project today and is concerned about scaling a Ruby on Rails project. Checkout the full agenda and tickets at https://friendlyrb.com We have a special offering 4+1 (buy 4…
Read More
Using RuboCop for Code Quality and Style Enforcement in Rails Projects

Using RuboCop for Code Quality and Style Enforcement in Rails Projects

Maintaining code quality and consistency is crucial in any software development project, especially in Ruby on Rails applications. RuboCop is a popular static code analysis tool that helps enforce coding standards and improve the overall quality of your code. This article will guide you through using RuboCop in your Rails projects. What is RuboCop?RuboCop is a Ruby gem that provides a collection of style guidelines and best practices for Ruby code. It analyzes your code against these guidelines and suggests improvements, helping you catch potential issues early in the development process. Setting Up RuboCopTo get started with RuboCop in your…
Read More
Ruby2html: Streamline Your Rails Views with Pure Ruby

Ruby2html: Streamline Your Rails Views with Pure Ruby

https://github.com/sebyx07/ruby2html As a Rails developer, I've often found myself wrestling with the limitations of ERB templates. The constant context switching between Ruby and HTML can be jarring, and complex logic in views can quickly become unwieldy. That's why I was excited to discover Ruby2html, a gem that allows you to write your entire view logic in pure Ruby. The Power of Ruby in Your Views Ruby2html isn't just another templating engine – it's a different approach to writing views. Instead of mixing Ruby and HTML, you write your entire view in Ruby, which is then transformed into clean, semantic HTML.…
Read More
Aplicação do React com Ruby para um Design System

Aplicação do React com Ruby para um Design System

Quando trabalhamos com aplicações Rails e queremos implementar um Design System utilizando React, seguimos alguns passos para garantir que tudo funcione corretamente e de forma integrada. 1. Verificação das Rotas do Rails:A primeira coisa a fazer é verificar se a rota que será utilizada já existe ou se precisará ser criada. Isso é importante porque o Design System pode ser aplicado tanto em rotas existentes quanto em novas rotas. 2. Identificação do Controller e Views:Uma vez identificada a rota, determinamos qual controller e actions estão envolvidos, além da view associada. Isso é fundamental para saber onde o novo componente React…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.