views:

103

answers:

2

Can I use stored procedures with ruby on rails ?

I am using mysql as database and ruby on rails.

please provide me any of the example for this.

+3  A: 

Duplicate ? if not:

class MyRubyClass < ActiveRecord::Base
    def self.select_some_records
       connection.select_all "exec mysql_stored_proc 'argument1', 'argument2'"
    end
end

to enable use of stored procedures look at this

Michel Kogan
+2  A: 

I would recommend you do your business logic IN rails.

Writing your own queries to execute in rails is awkward, error prone, and not likely portable to other databases.

reverebeer