RubyCademy (@rubycademy) 's Twitter Profile
RubyCademy

@rubycademy

The best Ruby code examples on 𝕏.
For more PRO Tips and foundational knowledge: 🔗 rubycademy.com

ID: 1047792827386810368

linkhttps://newsletter.rubycademy.com calendar_today04-10-2018 10:17:31

1,1K Tweet

3,3K Takipçi

0 Takip Edilen

RubyCademy (@rubycademy) 's Twitter Profile Photo

Use the end-of-options marker (in yellow) to pass options to IRB directly! How it works: → `rails c` starts the Rails console → `--` tells Rails to stop parsing options → `--noecho` is passed directly to irb #rubyonrails #irb

Use the end-of-options marker (in yellow) to pass options to IRB directly!

How it works:

→ `rails c` starts the Rails console
→ `--` tells Rails to stop parsing options
→ `--noecho` is passed directly to irb

#rubyonrails #irb
RubyCademy (@rubycademy) 's Twitter Profile Photo

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

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
RubyCademy (@rubycademy) 's Twitter Profile Photo

If I encounter one more `if ... then ... else ... end` block, I’ll go blind. 👀 Use the ternary operator instead! 🙏 #rubyonrails #ruby

If I encounter one more `if ... then ... else ... end` block, I’ll go blind. 👀

Use the ternary operator instead! 🙏

#rubyonrails #ruby
RubyCademy (@rubycademy) 's Twitter Profile Photo

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 you’re just swapping characters in a string, use `String#tr`, not `String#gsub`. 💚

Why? No regex engine, faster execution, cleaner intent.

#rubyonrails
RubyCademy (@rubycademy) 's Twitter Profile Photo

Want to assign default values to locals in your Rails partials? With Rails 7.1+, you can do it right in the `locals:` pragma! #rubyonrails

Want to assign default values to locals in your Rails partials?

With Rails 7.1+, you can do it right in the `locals:` pragma!

#rubyonrails
RubyCademy (@rubycademy) 's Twitter Profile Photo

⚠️ Your booleans might be skipping validations… Did you know that `toggle!` calls `update_attribute` under the hood, which skips ActiveRecord validations? #rubyonrails #activerecord

⚠️ Your booleans might be skipping validations…

Did you know that `toggle!` calls `update_attribute` under the hood, which skips ActiveRecord validations?

#rubyonrails #activerecord
RubyCademy (@rubycademy) 's Twitter Profile Photo

✨ FRESH BATCH OF CONTENT ✨ 💎 Faster string swaps • Smarter loops • Cleaner AI code 🔗 rubycademy.com #rubyonrails

✨ FRESH BATCH OF CONTENT ✨

💎 Faster string swaps • Smarter loops • Cleaner AI code

🔗 rubycademy.com

#rubyonrails
RubyCademy (@rubycademy) 's Twitter Profile Photo

Combine: - the `rails runner` command - with Bash heredocs to run multiline Rails scripts directly from your terminal! 🤩 PS: This is a common trick among seasoned Shell scripters. #rubyonrails

Combine:

- the `rails runner` command
- with Bash heredocs

to run multiline Rails scripts directly from your terminal! 🤩

PS: This is a common trick among seasoned Shell scripters. #rubyonrails