4 ms·
Rails has two ways to do this. You can do any select query returning active record objects with Model.find_by_sql("raw select query") And any query with a
by epochwolf 15y ago
Rails has two ways to do this. You can do any select query returning active record objects with
Model.find_by_sql("raw select query")
And any query with a driver dependent result using
ActiveRecord::Base.connection.execute("raw sql")
You can shorten the second one to simply "execute" by creating a method to wrap the functionality.