activerecord直接执行sql语句的写法ActiveRecord::Base.connection.execute

If the helpers provided by Active Record aren't enough you can use the execute method to execute arbitrary SQL:

Product.connection.execute( "UPDATE products SET price = 'free' WHERE 1=1" )



source: http://guides.rubyonrails.org/active_record_migrations.html

你可能感兴趣的:(rails)