π www.rubycademy.com π
15.05.2025 09:49 β π 1 π 0 π¬ 0 π 0@rubycademy.bsky.social
The best Ruby code examples. For more PRO Tips and foundational knowledge: π https://www.rubycademy.com
π www.rubycademy.com π
15.05.2025 09:49 β π 1 π 0 π¬ 0 π 0β οΈ Your booleans might be skipping validationsβ¦
Did you know that `toggle!` calls `update_attribute` under the hood, which skips ActiveRecord validations?
#rubyonrails #activerecord
Want to assign default values to locals in your Rails partials?
With Rails 7.1+, you can do it right in the `locals:` pragma!
π www.rubycademy.com
#rubyonrails
If youβre just swapping characters in a string, use `String#tr`, not `String#gsub`. π
Why? No regex engine, faster execution, cleaner intent.
#rubyonrails
If I encounter one more `if ... then ... else ... end` block, Iβll go blind. π
Use the ternary operator instead! π
#rubyonrails #ruby
Screenshot of news for All about code and Ruby from inside the newsletter
Find out what's new inside π All about Code and Ruby from @byroot.bsky.social , @bramjetten.dev @tenderlove.dev Vishnu M @hasumikin.bsky.social @jamie.schembri.me @Josef Strzibny @Matt Swanson @johnnunemaker.com @rubycademy.bsky.social and many more
28.04.2025 12:16 β π 4 π 3 π¬ 1 π 0Rails 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
"Rails is dead," they said! π #rubyonrails
25.04.2025 18:26 β π 3 π 0 π¬ 0 π 0