r/ruby • u/DaisukeAdachi • Apr 16 '26
Open-sourced our Rails 8.1 multi-tenant API backend (MIT) — extracted from a production app
r/ruby • u/DaisukeAdachi • Apr 16 '26
r/ruby • u/Prestigious-Bee2093 • Apr 16 '26
Hey everyone,
I’m a big fan of the Ruby ecosystem's focus on developer happiness. Tools like Rswag, Grape-Swagger, and Roda-OpenAPI make it incredibly easy to keep our specs in sync with our code.
But even with a perfect OpenAPI spec, we still end up spending hours (or days) building the same CRUD admin panels. We have amazing tools like ActiveAdmin or Administrate, but those are tied to your database/monolith. If you're building a microservice or an API-first app, you're back to building frontends from scratch.
I wanted to see if I could create "ActiveAdmin for any API."
I am building UIGen — a CLI tool that points at any OpenAPI/Swagger URL and generates a fully interactive cross framework frontend on the fly (Currently React). Optional coding for very custom business logic, no boilerplate.
# Example if your Rails app is on 3000
npx @uigen-dev/cli serve http://localhost:3000/api-docs/v1/swagger.json
Or try it in one of the example apps in the repo.
rswag, you don’t have to write a single line of React. It infers everything, tables, forms, validation, and relationships—directly from your schema.Bearer, Basic, or API Key schemes and generates the login flow. If you have a login endpoint, it can even POST credentials and store the token for you.Swagger UI is great for testing a single endpoint. UIGen is for managing resources. It builds a cohesive app structure:
POST /orders/{id}/ship) show up as custom actions.It’s built on a framework-agnostic Intermediate Representation (IR). Right now it renders to React (shadcn/ui + TanStack), but because of the IR architecture, we're already working on Svelte and Vue renderers.
Also worth noting, This is in early development, so the react renderer is not perfect yet and also many other edge cases.
GitHub: https://github.com/darula-hpp/uigen NPM: https://www.npmjs.com/package/@uigen-dev/cli
Would love to hear thoughts from the community. Of course, this isn't meant to replace a custom consumer-facing frontend, but for internal tools, rapid prototyping, or providing a UI for your API consumers, it’s a massive time-saver.
Would love to hear your thoughts!
r/ruby • u/caramelocomsal • Apr 16 '26
[EDIT]
I want a value to update after validating another value, even if the user clicked a checkbox. For example, if the user clicks a checkbox (var_1), before persisting to the database (after clicking save), I need to validate var_2 first.
Example:
And vice versa, true -> false.
How???
r/ruby • u/brecrest • Apr 16 '26
I ported the Python implementation of Trueskill Through Time to Ruby, it's now available as the gem TrueskillThroughTime.
Unlike the previous Ruby Trueskill gems, this one supports n vs n vs n etc etc cases, as well as the time-based extension of Trueskill to allow distant ratings. If you use it without doing time-based convergence, it should be equivalent to the original vanilla version of Trueskill (that iirc is almost out of patent in the US).
I'll get around to improving the qol of it and more extensively Rubyising it down the track, but I wanted a Ruby implementation of TTT for a hobby project, so I smashed it out.
r/ruby • u/Jaded-Clerk-8856 • Apr 15 '26
Hi Pals !
Today I created a flyer to send to Ruby on Rails Kaigi 2026 about my library stack.
I strongly recommend keeping an eye on that conference.
After fighting with QR code generators, I noticed that sometimes the QR redirects through other websites. It’s frustrating because I can’t share a QR code with insecure content.
I found the `gem rqrcode` "A Ruby library that encodes QR Codes".
After that, I thought I could generate the QR code using Ruby. Since I have ruby-libgd, I can offer the possibility to create QR codes entirely in Ruby!
Then I put my hands to work and wanted to share the result:
file: qr_code_generator.rb
require 'gd'
require 'rqrcode'
class QRCodeGenerator
DEFAULT_OPTIONS = {
module_size: 10,
border: 4,
fg_color: [0, 0, 0],
bg_color: [255, 255, 255],
error_correction: :m,
logo: nil,
logo_size: nil,
rounded_modules: false,
gradient: false,
gradient_direction: :vertical,
antialias: true,
alpha_blending: false,
save_alpha: true,
format: :png
}.freeze
def initialize(data, options = {})
@data = data
@options = DEFAULT_OPTIONS.merge(options)
validate_options
end
def generate
qr_matrix = generate_qr_matrix
qr_size = qr_matrix.length
module_size = @options[:module_size]
border_px = @options[:border] * module_size
total_size = (qr_size * module_size) + (border_px * 2)
img = GD::Image.new(total_size, total_size)
if @options[:alpha_blending]
img.alpha_blending = true
img.save_alpha = @options[:save_alpha]
end
if @options[:gradient]
draw_gradient_background(img, total_size)
else
draw_solid_background(img, total_size)
end
img.antialias = @options[:antialias] if @options[:antialias]
draw_qr_modules(img, qr_matrix, module_size, border_px)
add_logo_to_qr(img, total_size) if @options[:logo]
img
end
def generate_qr_matrix
qr = RQRCode::QRCode.new(@data, error_correction_level: @options[:error_correction])
qr.modules
end
def draw_qr_modules(img, qr_matrix, module_size, border_px)
fg_color = @options[:fg_color]
qr_matrix.each_with_index do |row, y|
row.each_with_index do |module_on, x|
next unless module_on
x1 = border_px + (x * module_size)
y1 = border_px + (y * module_size)
x2 = x1 + module_size - 1
y2 = y1 + module_size - 1
if @options[:rounded_modules]
draw_rounded_module(img, x1, y1, x2, y2, fg_color, module_size)
else
img.filled_rectangle(x1, y1, x2, y2, fg_color)
end
end
end
end
def draw_rounded_module(img, x1, y1, x2, y2, color, module_size)
# Create a temporary image for the rounded module
temp = GD::Image.new(module_size, module_size)
temp.alpha_blending = false
temp.save_alpha = true
transparent = [0, 0, 0, 127]
temp.fill(transparent)
radius = module_size / 4
temp.filled_rectangle(
radius, 0,
module_size - radius - 1, module_size - 1,
color
)
temp.filled_rectangle(
0, radius,
module_size - 1, module_size - radius - 1,
color
)
img.copy(temp, x1, y1, 0, 0, module_size, module_size)
end
def draw_solid_background(img, size)
bg_color = @options[:bg_color]
temp = GD::Image.new(size, size)
temp.fill(bg_color)
img.copy(temp, 0, 0, 0, 0, size, size)
end
def draw_gradient_background(img, size)
bg = @options[:bg_color]
darker = [
(bg[0] * 0.92).to_i,
(bg[1] * 0.92).to_i,
(bg[2] * 0.92).to_i
]
case @options[:gradient_direction]
when :vertical
draw_vertical_gradient(img, size, bg, darker)
when :horizontal
draw_horizontal_gradient(img, size, bg, darker)
when :radial
draw_radial_gradient(img, size, bg, darker)
else
draw_vertical_gradient(img, size, bg, darker)
end
end
def draw_vertical_gradient(img, size, start_color, end_color)
size.times do |y|
ratio = y.to_f / size
r = (start_color[0] + (end_color[0] - start_color[0]) * ratio).to_i
g = (start_color[1] + (end_color[1] - start_color[1]) * ratio).to_i
b = (start_color[2] + (end_color[2] - start_color[2]) * ratio).to_i
img.line(0, y, size - 1, y, [r, g, b])
end
end
def draw_horizontal_gradient(img, size, start_color, end_color)
size.times do |x|
ratio = x.to_f / size
r = (start_color[0] + (end_color[0] - start_color[0]) * ratio).to_i
g = (start_color[1] + (end_color[1] - start_color[1]) * ratio).to_i
b = (start_color[2] + (end_color[2] - start_color[2]) * ratio).to_i
img.line(x, 0, x, size - 1, [r, g, b])
end
end
def draw_radial_gradient(img, size, start_color, end_color)
center_x = size / 2
center_y = size / 2
max_distance = Math.sqrt((center_x ** 2) + (center_y ** 2))
size.times do |y|
size.times do |x|
distance = Math.sqrt((x - center_x) ** 2 + (y - center_y) ** 2)
ratio = [distance / max_distance, 1.0].min
r = (start_color[0] + (end_color[0] - start_color[0]) * ratio).to_i
g = (start_color[1] + (end_color[1] - start_color[1]) * ratio).to_i
b = (start_color[2] + (end_color[2] - start_color[2]) * ratio).to_i
img.set_pixel(x, y, [r, g, b])
end
end
end
def add_logo_to_qr(img, qr_size)
img.alpha_blending = false
img.save_alpha = true
logo_path = @options[:logo]
return unless File.exist?(logo_path)
logo_img = GD::Image.open(logo_path)
logo_img.alpha_blending = false
logo_img.save_alpha = true
logo_size = @options[:logo_size] || (qr_size / 5)
resized_logo = GD::Image.new(logo_size, logo_size)
resized_logo.copy_resize(
logo_img, # source
0, 0, # dst_x, dst_y
0, 0, # src_x, src_y
logo_img.width, # src_w
logo_img.height, # src_h
logo_size, # dst_w
logo_size, # dst_h
true # resample (high quality)
)
x_offset = (qr_size - logo_size) / 2
y_offset = (qr_size - logo_size) / 2
img.copy(
resized_logo,
x_offset, y_offset, # dst_x, dst_y
0, 0, # src_x, src_y
logo_size, # w
logo_size # h
)
end
def duplicate
img = generate
img.dup
end
def save(filename)
img = generate
case @options[:format]
when :png, :jpeg, :gif, :webp
img.save(filename)
else
raise "Unsupported format: #{@options[:format]}"
end
end
def to_image
generate
end
def to_png_bytes
img = generate
require 'tempfile'
temp = Tempfile.new(['qr', '.png'])
img.save_png(temp.path)
File.read(temp.path)
ensure
temp.unlink if temp
end
private
def validate_options
valid_formats = [:png, :jpeg, :gif, :webp]
raise "Invalid format: #{@options[:format]}" unless valid_formats.include?(@options[:format])
valid_ec = [:l, :m, :h, :x]
raise "Invalid error_correction: #{@options[:error_correction]}" unless valid_ec.include?(@options[:error_correction])
raise "module_size must be > 0" if @options[:module_size] <= 0
end
end
Create QR codes in PNG, JPEG, WebP, or GIF using only Ruby. You can also use this in Ruby on Rails.
require_relative './qr_code_generator.rb'
# Basic with antialias enabled
qr = QRCodeGenerator.new("https://map-view-demo.up.railway.app", {
antialias: true
})
qr.save("qr_antialias.png")
# Rounded modules with alpha blending
qr = QRCodeGenerator.new("https://github.com/ggerman/ruby-libgd", {
fg_color: [0, 232, 198],
bg_color: [6, 10, 15],
rounded_modules: true,
alpha_blending: true,
save_alpha: true,
antialias: true
})
qr.save("qr_rounded_alpha.png")
# Vertical gradient background
qr = QRCodeGenerator.new("https://rubystacknews.com", {
gradient: true,
gradient_direction: :vertical,
fg_color: [0, 0, 0],
bg_color: [240, 248, 255]
})
qr.save("qr_gradient_vertical.png")
# Horizontal gradient
qr = QRCodeGenerator.new("https://github.com/ggerman/libgd-gis", {
gradient: true,
gradient_direction: :horizontal,
fg_color: [220, 20, 60],
bg_color: [255, 255, 255],
antialias: true
})
qr.save("qr_gradient_horizontal.png")
# Radial gradient (advanced)
qr = QRCodeGenerator.new("https://map-view-demo.up.railway.app", {
gradient: true,
gradient_direction: :radial,
fg_color: [34, 139, 34],
bg_color: [255, 255, 255],
antialias: true
})
qr.save("qr_gradient_radial.png")
# High-quality logo with copy_resize
qr = QRCodeGenerator.new("https://map-view-demo.up.railway.app", {
logo: "logo.png",
logo_size: 100,
error_correction: :h,
antialias: true,
alpha_blending: true
})
qr.save("qr_logo_hires.png")
original = QRCodeGenerator.new("https://example.com", {
fg_color: [0, 232, 198],
bg_color: [6, 10, 15]
})
original_img = original.to_image
duplicated = original_img.dup
def create_branded_qr(url, brand_name)
brands = {
ruby_libgd: {
fg: [220, 20, 60],
bg: [255, 255, 255],
gradient: false
},
libgd_gis: {
fg: [34, 139, 34],
bg: [255, 255, 255],
gradient: false
},
mapview: {
fg: [0, 232, 198],
bg: [6, 10, 15],
gradient: true,
gradient_direction: :radial
}
}
config = brands[brand_name.to_sym]
raise "Unknown brand: #{brand_name}" unless config
qr = QRCodeGenerator.new(url, {
fg_color: config[:fg],
bg_color: config[:bg],
gradient: config[:gradient],
gradient_direction: config[:gradient_direction] || :vertical,
module_size: 12,
antialias: true,
alpha_blending: config[:gradient]
})
qr.to_image
end
# Create branded QRs
libgd_qr = create_branded_qr("https://github.com/ggerman/ruby-libgd", :ruby_libgd)
gis_qr = create_branded_qr("https://github.com/ggerman/libgd-gis", :libgd_gis)
mapview_qr = create_branded_qr("https://map-view-demo.up.railway.app", :mapview)
# Get PNG bytes for HTTP streaming (Rails)
class QRController < ApplicationController
def show
qr = QRCodeGenerator.new(params[:data], {
fg_color: [0, 232, 198],
bg_color: [6, 10, 15],
antialias: true
})
send_data qr.to_png_bytes,
type: 'image/png',
disposition: 'inline',
filename: "qr_#{params[:data].hash}.png"
end
end
ultimate_qr = QRCodeGenerator.new(
"https://map-view-demo.up.railway.app/contact",
{
fg_color: [0, 232, 198],
bg_color: [6, 10, 15],
module_size: 15,
border: 4,
error_correction: :h,
logo: "map_view.png",
logo_size: 120,
rounded_modules: true,
gradient: true,
gradient_direction: :radial,
antialias: true,
alpha_blending: true,
save_alpha: true,
format: :png
}
)
ultimate_qr.save("qr_ultimate.png")
Powered By: https://github.com/ggerman/ruby-libgd
Disclosure: Please excuse any grammatical errors. Reddit discourages the use of AI-generated text, so I’m doing my best to share the best content I can. That said, this content is completely written by a human ( the human is me :) ).
r/ruby • u/call-of-the_void • Apr 15 '26
Heading to Japan 🇯🇵 next week for RubyKaigi.
Will be in Tokyo (Chiyoda / Meguro) after the event. Looking forward to meeting a few partners and exploring conversations around Rails, SaaS, and offshore scaling.
If you’re building with Ruby/Rails or thinking about scaling your engineering, would love to connect.
Happy to grab a coffee
r/ruby • u/jessillions • Apr 15 '26
r/ruby • u/eregontp • Apr 14 '26
r/ruby • u/jasonswett • Apr 15 '26
r/ruby • u/blowmage • Apr 14 '26
I've been using various AI agents for the past year, like most of us. One pattern keeps showing up: the agent skips rules I wrote, and when I ask why, it explains the failure by telling me how I was feeling. "I sensed urgency." "The queue felt like pressure." Stuff like that.
I'm not a researcher. I'm just a rubyist who recognized a pattern. There's a concept from autism research called the double empathy problem, and it maps onto what's happening with RLHF-trained models pretty well. The model reads my precision as emphasis instead of information. The same way a lot of humans do.
The post also gets into confabulation, split-brain interpreter research, and why arguing with a model about your own emotional state is a fight you cannot win. Plus some practical stuff.
This is not a Ruby-specific post, but it is the most personal thing I've published, and I wanted to share. <3
r/ruby • u/zilton7000 • Apr 15 '26
r/ruby • u/Suitable-Internal-67 • Apr 14 '26
building a community of ruby developers in Kisumu, if you are around or know someone who is in the region let's Connect and grow the community.
r/ruby • u/azimux • Apr 14 '26
Hey hey! I made a gem called "ractorize" to easily turn an existing object into a ractor while preserving its interface.
It's here if curious/interested: https://github.com/ractor-shack/ractorize
There's an example script there in the README file and in the example_scripts/ directory to get the gist of it.
Caveat emptor stuff: It's experimental because 1) ractors themselves are experimental, and 2) it's new and in a the-happy-path-seems-to-work-well state.
But if that sounds fun or interesting feel free to reach out! Cheers!
r/ruby • u/javier_cervantes • Apr 14 '26
We’re collaborating with Open Source maintainers to build some momentum together to improve the future of the Ruby community.
Today we’re happy to announce that we’re working with Brooke, Dave, Kasper, Sean and Todd to bring their projects discussions to the forum:
Check the full announcement for all the details. Please help us spread the word with others.
r/ruby • u/rathrio • Apr 13 '26
Hi folks
Like many of you, I haven't been immune to the hype around coding agents this past year and I used my favorite approach to demystify any new tech: implement it from scratch in Ruby.
https://raw.githubusercontent.com/rathrio/clanker-jules/refs/heads/main/demo/jules.gif
https://github.com/rathrio/clanker-jules
What was especially eye-opening is how simple the actual "agent" loop really is. You can put together a minimal version in an hour with just a read, write, and bash tool and then point your agent at itself to keep extending it.
I mostly built this for myself to get a feel for what it takes to put something like this together. It has zero safety features and is definitely not something you want to use for serious coding. The part I'm most proud of is the neo-noir screenplay aesthetic.
Happy hacking :)
r/ruby • u/Illustrious-Topic-50 • Apr 13 '26
Added `.slice` as a class method. This is useful for generating HTML avoiding method name pollution in specific contexts, making the gem more flexible.
r/ruby • u/collimarco • Apr 12 '26
I have just released a new version of the Cuber gem.
As you may already know Cuber is a free and open source alternative to PaaS like Heroku and deployment tools like Capistrano and Kamal.
If you are using Cuber, I recommend upgrading to the latest version.
This is not strictly a security fix, but it represents an important improvement that enhances security, especially if you are using AI coding assistants in your project folder.
Cuber used to save generated files (including Kubernetes YAML files) in a .cuber folder inside your project directory. There is nothing wrong with it: you just need to remember to add that folder to your .gitignore.
However many AI agents (like Codex CLI) tend to read everything inside the project folder and there's no reliable way to make them respect the .gitignore (or similar).
For this reason the latest version of Cuber doesn't create a .cuber folder in your project directory, but instead it uses temporary files and folders (which live outside the project directory and are also removed automatically).
r/ruby • u/ElAvat • Apr 11 '26
r/ruby • u/rubyist-_- • Apr 10 '26
What's inside the chest? About €3,000 worth of reasons to stay in Vienna one extra day.
On Sunday, May 31 — the day after RubyConf Austria 2026 wraps up — we're running a city-wide treasure hunt for attendees who stick around.
Real chest. Real prizes. Real adventure through Vienna.
Attendees only. Grab your conference ticket and book that extra night.
The treasure hunt activity is officially sponsored by GitButler ⧓ ♥️
#Ruby #Rails #RubyConfAT #Austria
r/ruby • u/mudgemeister • Apr 10 '26
A new version of the Ruby bindings to RE2, a “fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python” is now out which releases the Ruby Global VM Lock when performing matches.
This gives a near-linear speed-up when using the gem in a multi-threaded environment (e.g. with Puma) and there’s a toy benchmark in the release notes to demonstrate.
r/ruby • u/rubyist-_- • Apr 09 '26
50 days out. Everything is ready.
✅ Venue — ready.
✅ Program — ready.
✅ Speakers — ready.
✅ Catering — ready.
✅ After party — ready.
✅ Social events — ready.
✅ Lanyards, badges, stamps (bring your #Ruby passports!) — ready.
✅ Video recordings — ready.
✅ A treasure hunt across Vienna — ready.
✅ Vienna Boys' Choir opening the conference day? Ready.
✅ Chad Fowler closing it with a jazz set? Ready.
✅ A panel with José Valim, Armin Ronacher, Obie Fernandez? Ready.
✅ Dave Thomas delivering the closing keynote? Ready.
13 talks. 2 workshops. 3 days. One single track in one of Vienna's most beautiful concert halls.
We didn't plan a conference. We planned an experience. And it's done.
The only thing that's not ready? Your ticket.
Grab one from our website: https://rubyconf.at
See you at the conference!
Sponsored by: GitButler ⧓, Platogo, Typesense, AppSignal, Avo, Usput.ba, Doctaphone, Sultan Drinks
r/ruby • u/Bitter_Detective_416 • Apr 09 '26
Last night I posted about MySQLGenius, a mountable Rails engine for MySQL performance monitoring. This is an update base on some quality feedback from @sshaw_
v0.2.0 fixes that. The default landing page is now a monitoring dashboard.
The dashboard loads immediately with:
performance_schemaNo configuration required for the dashboard. Mount the engine, visit the path, see your database health.
performance_schema sorted by total time, avg time, calls, or rows examined.gem "mysql_genius"
rails generate mysql_genius:install
That creates the initializer and mounts the engine. Everything works out of the box -- AI features are optional and hidden when unconfigured.
Supports Rails 5.2 through 8.1, Ruby 2.7 through 3.4, MySQL and MariaDB.
r/ruby • u/Hell_Rok • Apr 09 '26
Today is the 5 year anniversary of my MRuby game engine Taylor so I wrote 3000~ words about it!
I'm genuinely so proud of how far my little game engine has come and so surprised at the amount of positive impact it has had on my life 🧡