问题描述
我想从控制台删除一条记录.
I want to delete a record from the console.
我通过脚本/控制台登录,并且
I logged through script/console and
User.find(1).delete
$<User id: 1, ..............>
User.find(1)
ActiveRecord::RecordNotFound: Couldn't find User with ID=1
........
........
........
一切都很好,直到这里.
Everything looks fine till here.
但是当我退出控制台并通过脚本/控制台命令返回控制台时,我再次能够看到ID = 1的记录.
But when I exit the console and return back to console by script/console command, I am able again to see the record with id = 1.
该数据库不是本地数据库,我通过提供一个IP来通过database.yml连接.
The database is not local and I'm connecting through database.yml by giving an ip.
当我尝试在开发本地数据库上执行相同操作时,一切都很好.
when I try to do the same on the development local database, everything is fine.
有人可以解释发生了什么,我在哪里想念!
Can someone please explain whats happening and where am I missing!
谢谢
推荐答案
尝试
User.find(1).destroy
这应该在控制台中起作用,否则.
This should work in the console and otherwise.
这篇关于从控制台删除记录-Ruby on Rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!