💎 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 ...1 min read·railscraft.hashnode.devFeb 10, 2025
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...3 min read·railscraft.hashnode.devFeb 1, 2025
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...1 min read·railscraft.hashnode.devFeb 1, 2025
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...2 min read·railscraft.hashnode.dev1小Jan 27, 2025
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...2 min read·railscraft.hashnode.devJan 25, 2025