Ruby on rails 3 rails3.x如何基于行值编写updateall?
我希望在添加列后在迁移文件中执行以下SQL查询(使用同一行中的现有列值更新新字段) SQL语句在数据库上执行时工作正常,但在rails中,我使用ActiveRecord update_all方法尝试了多种语法,但没有成功Ruby on rails 3 rails3.x如何基于行值编写updateall?,ruby-on-rails-3,activerecord,Ruby On Rails 3,Activerecord,我希望在添加列后在迁移文件中执行以下SQL查询(使用同一行中的现有列值更新新字段) SQL语句在数据库上执行时工作正常,但在rails中,我使用ActiveRecord update_all方法尝试了多种语法,但没有成功 User.update_all("last_login=updated_at") 我得到以下错误 ActiveRecord::StatementInvalid: PGError: ERROR: current transaction is aborted, commands
User.update_all("last_login=updated_at")
我得到以下错误
ActiveRecord::StatementInvalid: PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block
: UPDATE "users" SET last_login=updated_at
很明显,我的语法中缺少了一些东西,但我不知道是什么。
有人能给我指出正确的语法吗
关于/J.语法确实正确,问题在于我必须回滚上一个
此语句工作正常。是否可能存在验证问题,如此链接上的示例?可能是,但在这种情况下不是。
ActiveRecord::StatementInvalid: PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block
: UPDATE "users" SET last_login=updated_at
User.update_all("last_login=updated_at")