Ruby + Rails : Distilled

Ruby + Rails : Distilled

@distilled.skillstopractice.com

A collection of posts of interest to Ruby and Rails developers. Hand-picked, high signal, always on topic. Maintained by @skillstopractice.com Also available as a feed: https://bsky.app/profile/did:plc:ip3trmvdbnlm4g7cdc5xs7ub/feed/aaaf5jle4pb7e

66 followers156 following18 posts

Ruby + Rails : Distilled reposted

I'm leaving Bluesky effective immediately and this is the reason why. I'll post when I get Mastodon set up + an RSS feed + newsletter.

Why@why.bsky.world

If you have problems with us as a company making revenue, then i've got some bad news.

Ruby + Rails : Distilled reposted

ViewComponents reduce bloat, simplify data, and create reusable frontend styling. Despite these benefits, they're often under-utilized in the Rails community. I've written a blog post refactoring a real-world example into isolated ViewComponents. joshfrankel.me/blog/viewcom... #ruby #rubyonrails

joshfrankel.meViewComponents, the Missing View Layer for RailsIf you’ve worked with Rails for any measure of time, then you know that Rails’ Views can quickly get out of hand. Between Helpers, instance variables, and inline logic, they quickly become bloated and...

Ruby + Rails : Distilled reposted

How do you manage error classes in your app? - Granular — Domain::Specific::NotFoundError - Generic/Reusable — Error::NotFound - Not — StandardError/raise 'x' Personally, I create my own error classes so I can see what's wrong at a glance, even if it means catching existing ones. #RubyLang

Already several good RSS feeds in the thread. Keep them coming! Discoverability is hard these days and RSS was one of those lovely tools that deserves a comeback.

Ruby + Rails : Distilled@distilled.skillstopractice.com

If you've got a blog where you (at least sometimes) write Ruby-related posts, please reply with a link to your RSS feed below. I am going to try to start keeping an eye on those as well and sharing interesting stuff I find from time to time.

Ruby + Rails : Distilled reposted

Don't want to expose a class' initializer in Ruby? Making it private is easy! Just use `private_class_method :new`. This conveys intent that your class is not designed to be initialized from outside — perfect when you want to use the factory pattern.

Ruby + Rails : Distilled reposted

How to automatically trigger a file download with Turbo? The user triggers the creation of a file. That file is created using a background job. I could update the view using Turbo Streams (e.g. render a 'Download Now' button). But I'd like download to automatically start 🤔 #rubyonrails

Ruby + Rails : Distilled reposted

Ruby + Rails : Distilled reposted

hey #RubyLang folks - our tests against Ruby head in sentry-ruby started failing yesterday with: LoadError: cannot load such file -- cgi/cookie I'm disabling ruby head version in our CI matrix for the time being but maybe there's a fix somewhere?

Ruby + Rails : Distilled reposted

Your periodic reminder that consolidating a wobbly design is worse than a waste of time, it interferes with further improvement. Sometimes the best thing is put all the elements in one pile until the fault lines become clear. #AugmentedCoding #GeniesDesignBadly

Ruby + Rails : Distilled reposted

What's the best host for running a Ruby application, that stores files on the server, and runs sqlite as the database, on the server?

Ruby + Rails : Distilled reposted

Replying to @hansschnedlitz.com

Having setters that appear to be at the instance level apply at the class level is something that (for me) definitely would be against the Principle of Least Surprise. An easy way to define class level accessors is nice but hard to see the use case for the instance level behavior.

Ruby + Rails : Distilled reposted

TIL about the ActiveSupport `mattr_accessor` method. It defines both class and instance accessors for class attributes. Handy little shortcut! 🔧 #ruby #rubyonrails

Ruby + Rails : Distilled reposted

Consider using pattern matching in Ruby. I wanted to update a user's location (RGeo Point) from an endpoint which receives a JSON object: { lat: ..., lng: ... }. Using pattern matching, we can detect such an object's shape, falling back to a catch-all (_) with an if statement for regular Points.

Ruby + Rails : Distilled reposted

What's the "Rails" way of designing a multi-step workflow with background jobs? Each job triggering the next, active record callbacks, state machines or something else? Help!

Ruby + Rails : Distilled reposted

TinyBits is getting a new interesting feature, you can now (using the repo's head) supply the pack/unpack method with an external dictionary. For shorter messages with no duplicate strings this can lead to a dramatic size reduction, from 96 to 34 bytes in the example below

Ruby + Rails : Distilled reposted

Ruby + Rails : Distilled reposted

who up there writing their blog? i want to see yalls blogs! criteria: - you wrote at least a post in 2025 - it doesn't force a paywall so we can actually read it

Ruby + Rails : Distilled reposted

With charge-per-request 3rd-party services (not only LLM APIs), how are you managing spending limits within your apps? I know some of these services have budget features, but I'm more interested in strategies where you have your own spend control -- e.g. rate limiting, token buckets, alerts...

Ruby + Rails : Distilled reposted

Who's actually using #Ruby LSP in #VSCode to run tests? I am trying it out today and its command to run all tests from current file seems to be running *each test scenario* in a separate process. This means that running all tests is dead slow. Am I doing something wrong?

Ruby + Rails : Distilled reposted

Anyone have better approaches to wiping Active Storage files after #RSpec test runs in #RubyOnRails? ``` config.after(:suite) do dir = ActiveStorage::Blob.services.fetch(:test).root FileUtils.rm_rf(dir) FileUtils.mkdir_p(dir) FileUtils.touch(File.join(dir, ".keep")) end ```

Ruby + Rails : Distilled reposted

Using database constraints (not nulls, foreign keys, unique compound indexes, etc.) in your Rails app isn't just good for data integrity. It also indicates system intent to others in a way that using Active Record validations alone just can't.

Ruby + Rails : Distilled reposted

I love what you can do with Hotwire & a bit of Stimulus 🤩 Here's a quick way to lazy-load some content on click using an empty turbo frame. Setting the source attribute automatically loads the content. #rubyonrails

Ruby + Rails : Distilled reposted

When a controller is full of custom actions named: - `#create_[thing]` - `#update_[thing]` - `#delete_[thing]` It usually means that `[thing]` is a missing concept in your domain. Consider extracting those actions into a new `[things]_controller.rb` class or something similar.