Invoking a large set of SQL from a Rails 4 application

前端 未结 8 1023
有刺的猬
有刺的猬 2020-12-30 07:11

I have a Rails 4 application that I use in conjunction with sidekiq to run asynchronous jobs. One of the jobs I normally run outside of my Rails application is

8条回答
  •  执笔经年
    2020-12-30 07:34

    I agree with Sharagoz, if you just need to run a specific query, the best way is to send the query string directly into the connection, like:

    ActiveRecord::Base.connection.execute(File.read("myquery.sql"))
    

    If the query is not static and you have to compose it, I would use Arel, it's already present in Rails 4.x:

    https://github.com/rails/arel
    

提交回复
热议问题