activerecord直接执行sql语句的写法ActiveRecord::Base.connection.execute
IfthehelpersprovidedbyActiveRecordaren'tenoughyoucanusetheexecutemethodtoexecutearbitrarySQL:Product.connection.execute("UPDATEproductsSETprice='free'WHERE1=1")source:http://guides.rubyonrails.org