还想请教一下update users set a=1 where id in (1,2,3)这句在rails中该如何写呢
云(11753503) 18:31:29
ActiveRecord::Base.connection.execute(str)
[上海] Jerry(40578681) 18:34:38
人家要rails的写法
[上海] Jerry(40578681) 18:35:08
User.update_all({:a => 1}, :id => [1,2,3])
[上海] Jerry(40578681) 18:35:24
User.update_all({:a => 1}, {:id => [1,2,3]})
云(11753503) 18:35:55
你这样写sql中update有几条?
[上海] Jerry(40578681) 18:36:36
1
[上海] Jerry(40578681) 18:36:45
>> Proposal.update_all({:user_id => 1}, :id => [1,2])
[上海] Jerry(40578681) 18:36:56
AREL (1.4ms) UPDATE "proposals" SET "user_id" = 1 WHERE ("proposals"."id" IN (1, 2))