RoR and stored procedures

Hi all,

I was wondering about what is the general consensus regarding using SQL
stored procedures in RoR. Based on the fact that stored procedures are
not mentioned in most (any) of the RoR manuals I read, I can conclude
their usage is discouraged.

Is there any particular reason against using SPs?

Thanks

Stored procedures put logic into the database. A place where it’s hard
to test, hard to version control, hard to access, and typically
written in a low-level language that’s a pain to deal with. Every now
and then, you might find yourself in a situation where they’re
actually worth it for performance reasons. Just like some times it
makes sense to write a piece of your application in C.

Treat stored procedures like C: Avoid it like the plague until it’s
your only hope for survival.

I think, in general, people using Rails prefer to have all their code
within their Rails app rather than use stored procedures.

I use stored procs all the time with Rails, because I prefer to have
the database “protect itself” from bad data, rather than rely on the
application/s to do it for me. That’s the big issue for me, although
I also use stored procs with Rails for other purposes.

It seems to be as much individual preference, and different
experiences, as anything else - I don’t believe either approach is
“better” than the other.

Regards

Dave M.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs