Rails rails console 怎么修改属性值

zealinux · July 11, 2013 · 2070 hits

相当与修改 mysql 的一列。

我想把某一列(外键)修改一下,统一定位到新的值上。

不知道怎么弄。


我试出来了,原来这么简单。

travels = Travel.all
travels.each do |t|
  t.start_city_id += 100
  t.save!
end
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.