DEV Community

Patrick Wendo
Patrick Wendo

Posted on

3

Rails is Pretty Intuitive once you get used to it.

I am currently working with background jobs in Rails through Active Job. And I needed some code to run before the job starts. So I thought,

Typically when you are working with the controllers and you want to run some code before an action you have a before_action callback. In stimulus reflex, we have the before_reflex callback. It should be safe to assume that Active Job must have a before_perform callback

So I just set that up real quick and what do you know it run. I checked the docs just to make sure I was not having some vivid hallucination and true enough there is a before_perform callback, as well as a couple other useful ones.

This may not seem like much, but the ability to guesstimate what type of functions may be defined on a class is one of the few things I love about rails and ruby in general. It's like how the Enumerable class from which arrays, sets and hashes all inherit allows you to know that there are some methods that will always exist between these classes. And how a function ending in a question mark will return a boolean while one ending in an exclamation mark will do some potentially destructive action on whatever object calls it.

Rails and Ruby is pretty awesome when it comes to the developer experience.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️