Introduction
In this week’s edition, top picks cover everything from practical Rails tips to AI-powered features. Highlights include how Thoughtbot built a Rails feature with ChatGPT and Active Job, a deep dive into Rails’ handy extract_options!
method, and best practices for protecting sensitive data in your logs. Plus, explore new experimental features in RailsEventStore, insights on Ruby debuggers, and a fresh tutorial on building an AI sales agent using Rails and OpenAI GPT-4.1 to automate lead qualification and meeting scheduling.
Some Helpful Resources :
Top Picks ⭐
Building a Rails Feature with AI and Active Job
In a recent livestream, thoughtbot developers Chad Pytel and Kasper Timm Hansen showed how they built a feature in their Rails app to enrich company data—like founding year or industry—without relying on a third-party service like Apollo. Instead, they used ChatGPT’s function-calling feature through the Ruby OpenAI gem.
They wrote tests first, defined a clear schema for expected data, and made tweaks to get more consistent results. They also used
ActiveJob::Performs
to handle background jobs easily.While the data wasn’t always perfect, they showed how AI can still add meaningful value to Rails apps.
https://thoughtbot.com/blog/ai-in-focus:building-a-rails-feature-with-ai-and-active-job
Extracting Options from Arguments in Rails
The author shares how Rails has a neat helper called
extract_options!
that makes it easy to pull out an options hash from a method’s argument list. Instead of juggling default values or guessing if the last argument is a hash, you can do:
options = args.extract_options!
Rails checks if the last element is a plain hash, removes it, and returns it—or gives you an empty hash otherwise. The remaining arguments are left clean. This keeps method APIs snappy and adaptable: you can add new options later without breaking existing calls.
Author walks through real-world examples, from a
notify
helper to how Rails routes use it internally, and even shows how you can use it in your own code, like a custom logger.He also explains Rails’ implementation of
extract_options!
, including how it only grabs plainHash
instances unless you override that behavior. It’s a tiny trick with big impact for keeping your Rails methods flexible and developer-friendly
https://www.writesoftwarewell.com/extract-options-from-arguments-in-rails/
Prevent logging sensitive information in Rails, and beyond
The author dives into how Rails helps protect sensitive data by filtering out private request parameters—like passwords, tokens, SSNs, and more—from appearing in your logs by default .
He highlights that Rails’s default filters are a great starting point and point out that any data meant to be kept private should ideally be encrypted—Rails will then automatically filter those encrypted attributes too thoughtbot.com.
The author also brings up an important reminder: if you’re using external clients like Faraday for HTTP requests, Rails won’t filter sensitive data automatically—you’ll need to set that up yourself .
Bottom line: Rails gives you a solid foundation for parameter filtering, but you still need to be proactive about protecting sensitive data in external services.
https://thoughtbot.com/blog/parameter-filtering
Latest 🔥
10 Best Practices for Writing Clean & Maintainable Rails Code
RubyroidLabs shares practical tips for writing clean and maintainable Rails code: stick to MVC conventions, break out complex logic into service objects or POROs, and keep methods short and focused.
They emphasize writing DRY, well-formatted code using tools like RuboCop, testing thoroughly with RSpec or Minitest, and offloading long tasks to background jobs with Sidekiq or ActiveJob.
Performance matters too—eager-load associations, use
pluck
when needed, and apply caching wisely.The post encourages continuous refactoring and thoughtful design, reminding us that clean code isn’t just about elegance—it’s about making future changes easier
https://rubyroidlabs.com/blog/2025/06/best-practices-clean-and-maintainable-ror-code/
Batch mapper in RailsEventStore - how initial idea evolved into experimental feature
Arkency (the team behind Rails Event Store) experimented with a smart new “batch mapper” feature that streamlines how you apply transformations to groups of events.
Instead of mapping events one by one, you can define a pipeline of transformation steps (like encryption, JSON serialization, or upcasting) and apply them across batches — saving time and reducing boilerplate.
This experimental approach builds on their existing
PipelineMapper
abstraction, letting developers declaratively compose mappings and transformations for entire event batches.It makes it easier to evolve event schemas, encrypt or serialize data consistently, and handle upcasting — all in one clean, efficient pipeline.
Inside Ruby Debuggers: TracePoint, Instruction Sequence, and CRuby API
JetBrains pulls back the curtain on how Ruby debuggers really work—from basic
puts
debugging and interactive consoles (binding.irb
/binding.pry
) to serious tools likebyebug
, thedebug
gem, and the RubyMine visual debugger.They explain each approach’s trade-offs: simplicity vs. flexibility vs. power and performance.
The post teases a deeper follow-up that will dive into debugger internals and even guide you through building a basic debugger yourself, giving you a better understanding of Ruby’s under-the-hood tools .
https://blog.jetbrains.com/ruby/2025/06/inside-ruby-debuggers/
Understanding config/database.yml in Ruby on Rails
The
config/database.yml
file in Rails sets up database connections for different environments, using shared defaults and environment-specific settings. It’s best practice to use environment variables for sensitive info.Rails also supports multiple databases and advanced options like read/write splitting. While tailored for ActiveRecord, other databases like MongoDB require separate configs.
https://rubystacknews.com/2025/06/11/understanding-config-database-yml-in-ruby-on-rails/
How to use Rails Authentication Generator Test Helpers
This video shows how to test Rails authentication using a new session test helper that manages login via session cookies. It covers writing integration tests for guest redirects and logged-in access, and explains how to handle cookies in system tests by injecting them directly into the browser to speed up tests.
This improvement is planned for upcoming Rails releases and helps make auth testing easier and faster
How to Build an AI Sales Agent With Ruby on Rails
This AI sales agent, built with Rails and OpenAI GPT-4.1, chats with visitors to qualify leads and book meetings automatically. It uses a knowledge base of business documents split into chunks with embeddings to fetch relevant context and answer questions accurately.
The app manages agents, chats, messages, and appointments, allowing dynamic scheduling and easy resource uploads—helping your AI work for you 24/7.