Ruby + Rails : Distilled

by @skillstopractice.com

Hand-picked list of posts that Ruby + Rails devs might find interesting. Maintained by: Gregory Brown ( @skillstopractice.com ) See how it works here: https://www.skillstopractice.com/distilled-faq Rather follow as an account instead of a feed? @distilled.skillstopractice.com

Pull to refresh
Jamie Schembri @jamie.schembri.me · May 15
0

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.

Jamie Schembri @jamie.schembri.me · May 12
0

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.

Mohamed Hassan @oldmoe.bsky.social · May 9
1

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

Andrea Fomera @afomera.dev · Apr 28
0

Feel like I'm missing something obvious but there's not a good way to filter params from `inspect` in Rails is there? My workaround is below, but hoping I'm missing something 😅

RubyCademy @rubycademy.bsky.social · Apr 28
0

Rails 8 introduced `rate_limit` for controllers. You can combine it with a `handle_rate_limit` method + a `BusyController` to centralize how you respond to throttled requests. Keeps things clean and makes it super easy to extend later. #rubyonrails

John Nunemaker @johnnunemaker.com · Apr 22
0

Can you block ip addresses via Flipper? Yes, yes you can. Whipped this together this morning for a bad actor. I should probably do something more sophisticated but sometimes this is all you need.

Hans Schnedlitz @hansschnedlitz.com · Apr 21
2

I just realized Rails' 'titlecase' does not actually give you true, stylistically correct title case. Not a big deal, just caught me off guard 😅 Now I'm wondering if someone has gone through the effort of implementing that?

Adam McCrea @adamlogic.com · Apr 17
0

If you have more than one worker process sitting idle while the job queue is empty, you're throwing away money. And for queues with an SLO > 30 seconds, that number drops to zero.