💎 in the docs: ActionController#log_atI love digging through the docs and finding an example that kind of explodes your brain a bit—some piece of functionality you might otherwise gloss over. Take this one from the Rails docs for log_at. At first glance, I didn’t realize how useful this ...Feb 10, 2025 · 1 min readrailscraft.hashnode.dev
Cleaner Rails Controllers with before_actionIf you have two or more render statements in your controller action, you might consider extracting some of the logic into a before action. Why? Because rendering or redirecting in a before_action will halt the request cycle and remove the need for an...Feb 1, 2025 · 3 min readrailscraft.hashnode.dev
Advice Comes with an Implied AsteriskIn software development we’re often given advice in absolute terms: “Service Objects are an anti-pattern.” “Keep your controllers skinny.” “Vanilla Rails is enough.” In the Ruby on Rails community, we all know DHH has a reputation for writing wi...Feb 1, 2025 · 1 min readrailscraft.hashnode.dev
Keep Your Controllers CRUD-yAnytime your controllers start to accumulate non-standard CRUD (Create, Read, Update, Delete) action names, you may consider extracting the action into a new controller where the action can become one of the standard CRUD action names. Often times, y...1小Jan 27, 2025 · 2 min readrailscraft.hashnode.dev
Consistently Handle Errors with a ModelErrors Concern💡 Trigger Warning! This approach may be considered controversial, especially since it touches on using exceptions for control flow. This is a pattern you can use in your Rails projects to keep your controllers lean. It works especially well in Rai...Jan 25, 2025 · 2 min readrailscraft.hashnode.dev