从控制台删除记录

从控制台删除记录

本文介绍了从控制台删除记录-Ruby on Rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从控制台删除一条记录.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 09:30