Custom SQL query without Corresponding Table

后端 未结 3 843
遇见更好的自我
遇见更好的自我 2021-01-30 14:55

I have a SQL query that isn\'t table-specific and I don\'t know how to handle it with Ruby On Rails.

Here my SQL query (you don\'t need to understand it):

SELE         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 15:27

    You can also grab the ActiveRecord connection and call select_all:

    ActiveRecord::Base.connection.select_all('select * from foo').each do |e|
      puts e.inspect
    end
    

提交回复
热议问题