Rails 3 execute custom sql query without a model

后端 未结 5 1461
鱼传尺愫
鱼传尺愫 2020-11-27 12:20

I need to write a standalone ruby script that is supposed to deal with database. I used code given below in rails 3

@connection = ActiveRecord::Base.establis         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 13:12

    Maybe try this:

    ActiveRecord::Base.establish_connection(...)
    ActiveRecord::Base.connection.execute(...)
    

提交回复
热议问题