When people build an AI research product, the first architectural decision is often which agent framework to use. That decision quickly leads to more decisions: how to run the agent loop, connect the model, expose tools, preserve state, browse the web, recover from failures, and present the result. But the agent runtime is not usually what makes a research workflow valuable. The value is in…
Working on a legacy Rails codebase can be challenging. But you can start navigating and working on it effectively with a good strategy. This blog post discusses common steps when working in a legacy codebase. This article does not talk about optimizing the codebase; it is only about understanding and navigating it. Because it does not make any assumptions. Understanding The Project 🔗 Each and…
Before Rails 8 we always used something like the devise gem for authentication. Even though Rails has all the features to build authentication, It was difficult to implement compared to devise gem. Rails 8 addresses this problem with an authentication generator. One good thing about this is that it is completely optional as a generator. You can still go with other authentication providers or build…
As Rails developers, we often focus on writing clean, efficient Ruby code. However, as the application grows optimizing database performance is equally crucial for creating responsive applications. One of the most powerful tools in our arsenal for database optimization is indexing. Here I will talk about PostgreSQL indexing from a Rails developer’s perspective. The query plan generated by…
Rails Active Record is a powerful ORM that simplifies database operations, but complex queries can sometimes lead to performance issues. We can use EXPLAIN to find out details about why a query is not performing well. In this post, we’ll explore the Active Record Explain feature and how to understand it’s output. We’ll cover the basics of using Explain, interpreting its output,…
The convenience and power of Active Record allows you to interact with your database in a more Ruby-like way, making it easier to write efficient and readable code. However, as with any complex system, performance can sometimes take a hit when using Active Record. One common scenario where performance may suffer is when counting records in your database. In any Rails app, A simple count method…
In Ruby on Rails, A generator is a tool that helps create scaffolding (basic code structure). By default, Rails provides several built-in generators like rails generate scaffold , rails generate controller , etc. Many of the gems come with their own Rails generators too. A custom generator is used to create a customized scaffolding for your application. Custom generators in Rails allow developers…
When building applications in Ruby on Rails, We store data in Plain Old Ruby Object (called PORO) value objects. This is a common pattern, We store data directly in service objects using attr_accessor . But in some cases we might have to cast data from string. For this, we do have to cast those attributes. Traditional Approach 🔗 class Product attr_accessor :name , :price , :released_at ,…
Active Record strict loading is an awesome feature in Rails that can significantly improve your application’s performance by preventing N+1 queries. In the past days before Rails 6.1, We mainly used bullet gem to statically scan this. But now, It can be explicit in the code using strict_loading . Let’s see what strict loading is, how to use it, and see some examples. What is N+1 issue…