标签: destroy

为什么我的异常没有被Laravel破坏方法捕获?

为什么我的例外没有被抓住?

    try {
        \Account::destroy($id);
        return Redirect::to("/manager/account")
                            ->with("success_message", "Item excluido com sucesso");
    } catch (Exception $e) {
        return Redirect::to("/manager/account/{$id}/edit")
                        ->with("error_message", "Erro ao excluir item");
    }
Run Code Online (Sandbox Code Playgroud)

SQLSTATE [23000]:完整性约束违规:1451无法删除或更新父行:外键约束失败(imob_io.users,CONSTRAINT users_account_id_foreignFOREIGN KEY(account_id)REFERENCES accounts(id))(SQL:从accountswhere id= 2 删除 )

destroy laravel

1
推荐指数
1
解决办法
1912
查看次数

水晶 - 类破坏的方法

是否有一个在销毁时调用的类方法?

new在类上使用时,该initialize方法被调用,是否有destroy等价的?
当不再使用类时,我需要确保数据库正确关闭(程序在数据库关闭后继续运行).

database destroy crystal-lang

1
推荐指数
1
解决办法
55
查看次数

为什么我无法删除此标签 (Tkinter)

我只是在玩弄和测试 python 中的东西。对于更大项目的概念验证代码的一部分,我需要创建然后删除标签。不幸的是,在我创建标签然后尝试将其删除后,当我尝试.destory()使用标签时出现此错误:

AttributeError: 'NoneType' object has no attribute 'destroy'

我听说如果你的标签中没有任何内容,你会得到这个错误,所以它是“无”,但我的有文字。这是代码:

from tkinter import*
import random
import time

root = Tk()
root.geometry("800x500")
root.title("amazing")

def one():
    label1 = Label(root, text="one", font=("Comic Sans MS", 30),  fg="purple").pack()
    time.sleep(2)
    label1.destroy()

def two():
    label2 = Label(root, text="two", font=("Comic Sans MS", 30),  fg="purple").pack()
    time.sleep(2)
    label2.destroy()

def doit():
    rchoice = [two, one]
    selected = random.choice(rchoice)
    return selected()

Button = Button(root, text="Button", width=15, height=3, font=("Comic Sans MS", 20), fg="blue", bg="lightgreen", command=doit).pack(pady=50)

root.mainloop()
Run Code Online (Sandbox Code Playgroud)

python label tkinter destroy

1
推荐指数
1
解决办法
341
查看次数

如何在 Java 14 中销毁 SecretKey?

我试图Secretkey在解密后清除我的。从我读过的内容来看,SecretKeys可以通过destroy自 Java 8 以来的方法销毁。我使用的是 Java 14,所以它应该是可能的。

但是,每当我在键上使用 destroy 方法时,DestroyFailedException都会抛出 a 。我还看到人们在他们的代码中忽略了该异常,但是,如果我这样做,我可以在调用destroy方法后打印密钥。

这是我的解密方法:

private byte[] decrypt(byte[] encryptedText, char[] password) throws InvalidKeyException,
        InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException,
        InvalidKeySpecException, IllegalBlockSizeException, BadPaddingException, DestroyFailedException {

    ByteBuffer bb = ByteBuffer.wrap(encryptedText);

    byte[] iv = new byte[ivLengthByte];
    bb.get(iv);

    byte[] salt = new byte[saltLengthByte];
    bb.get(salt);

    byte[] cipherText = new byte[bb.remaining()];
    bb.get(cipherText);

    SecretKey key;
    key = crypto.getAESKeyFromPassword(password, salt);

    Cipher cipher;
    cipher = Cipher.getInstance(algorithm);

    cipher.init(Cipher.DECRYPT_MODE, key, new GCMParameterSpec(tagLengthBit, iv));

    byte[] plainText = cipher.doFinal(cipherText); …
Run Code Online (Sandbox Code Playgroud)

java encryption destroy secret-key aes-gcm

1
推荐指数
1
解决办法
223
查看次数

取消链接功能不释放磁盘空间

我在php中测试Unlink以删除一些文件.确实删除了文件,我再也看不到了,但令人惊讶的是我的硬盘空间永远不会消失.

我想完全删除一个文件.

php unlink delete-file destroy

0
推荐指数
1
解决办法
841
查看次数

KnockoutJs 1.3 beta._destroy:false在ui上的结果与_destroy:true相同

使用asp.net mvc,我传递一个viewmodel并获取knockout来映射一个viewmodel并绑定到它.

这对我来说都很好,我想做的是跟踪删除.

我想我可以通过添加_destroy属性但将其设置为false来完成此操作.

我希望ui会忽略这个,直到destroy将其设置为true.

但事实似乎并非如此,仅仅存在这种财产就会被视为被破坏.

这是一个错误还是我处理这个错误?

非常感谢,Kohan

  var model = [{"Id":1,"Name":"Bikes","Parent":null,"_destroy":false},
  {"Id":2,"Name":"Components","Parent":null,"_destroy":false},
  {"Id":3,"Name":"Clothing","Parent":null,"_destroy":false},
  {"Id":4,"Name":"Accessories","Parent":null,"_destroy":false},
  {"Id":5,"Name":"Mountain Bikes","Parent":1,"_destroy":false},
  {"Id":6,"Name":"Road Bikes","Parent":1,"_destroy":false},
  {"Id":7,"Name":"Touring Bikes","Parent":1,"_destroy":false},
  {"Id":8,"Name":"Handlebars","Parent":2,"_destroy":false}] ;
Run Code Online (Sandbox Code Playgroud)

上述元素均不会显示.甚至"_destroy":null也有同样的效果.

问题的工作实例......

http://jsfiddle.net/jy53e/6/

更新:似乎是映射扩展的问题.

javascript destroy asp.net-mvc-3 knockout-mapping-plugin knockout.js

0
推荐指数
1
解决办法
317
查看次数

覆盖rails活动记录会破坏has_and_belongs_to_many关系的意外删除

我有一个继承自ActiveRecord :: Base的Commentable类和一个继承自Commentables的Event类.

我已经覆盖了这两个类中的destroy方法,并且Event.distroy调用了super.然而,一些意外的事情发生了.具体而言,将删除事件的has_and_belongs_to_many关联.我认为这种情况正在发生,因为一些模块被包含在Commentables和Event类之间,但不确定是否有办法阻止它.

这是简化的代码:

class Commentable < ActiveRecord::Base
  has_many :comments

  def destroy
    comments.destroy_all
    self.deleted = true
    self.save!
  end

end

class Event < Commentable
  has_and_belongs_to_many :practitioners, :foreign_key => "commentable_id"

  def destroy
    #some Event specific code
    super
  end

end
Run Code Online (Sandbox Code Playgroud)

我不想从数据库中删除行,只需设置一个"已删除"标志.我也不想删除任何关联.但是,在Event.destroy和Commentable.destroy之间的某处,其他一些rails代码会破坏has_and_belongs_to_many表中的记录.

知道为什么会这样,以及如何阻止它?

inheritance activerecord ruby-on-rails super destroy

0
推荐指数
1
解决办法
3635
查看次数

Tkinter从正在运行的程序中删除按钮

我试图创建一个功能,创建并在屏幕上放置一个按钮(带网格),按钮的命令将自行删除(或任何其他小部件),但我没有这样做.

def a(self):
    self.call_button = Tkinter.Button(self.root, text = "Call", command=self.b).grid(row = 5, column = 5)

def b(self):
    self.call_button.destroy()
Run Code Online (Sandbox Code Playgroud)

a创建按钮,b删除它,但是当我在b上调用时,它说"NoneType对象没有属性破坏"

我该如何正确地做到这一点?

python user-interface tkinter widget destroy

0
推荐指数
1
解决办法
2万
查看次数

从php中的多个会话中销毁一个会话

Session我的剧本中有5个.我想要destroy两个人.

<?php
  session_start();
  $_SESSION['productid'] = "123";
  $_SESSION['imglink'] = "x.png";
  $_SESSION['oldprize'] = "120";
  $_SESSION['spacialprize'] = "100"
  $_SESSION['productname'] = "AC";
?>
Run Code Online (Sandbox Code Playgroud)

php session destroy

0
推荐指数
1
解决办法
2965
查看次数

通过按GUI.Button在C#中添加/删除组件在Unity3d中无法正常工作

我很难尝试在C#中添加和删除js脚本作为游戏对象的组件,因为我是Unity和编码的新手.

我有一个需要在运行时在MainCamera中添加的js,点击GUI.Button.稍后必须使用相同的GUI销毁此脚本.单击按钮.

我已设法在运行时使用以下代码片段在MainCamera上添加js脚本:

public Bearing addBearing; // "Bearing" is the js script and "addBearing the variable to    reference this

//some other codding
.
.
// Add and remove Bearing with this button
public bool addBearing;

void OnGUI(){
if(GUI.Button(new Rect(10,10, 100, 100), "Bearing"))

addBearing= !addBearing;

if(addBearing){
addBearing  = GameObject.FindGameObjectWithTag("MainCamera").gameObject.AddComponent<Bearing>();

}else{

GameObject.FindGameObjectWithTag("MainCamera").gameObject.GetComponent<Bearing>();

Destroy(GetComponent<Bearing>());
Run Code Online (Sandbox Code Playgroud)

问题是,当我点击"Bearing"GUI.Button时,js脚本"Bearing"不会被破坏.

这段代码逻辑中缺少一些东西,但我在编写C#以找到解决方案方面没有经验.那么,有人可以帮助我帮忙解决这个问题吗?非常感谢.谢谢大家的答案.

c# button unity-game-engine destroy unityscript

0
推荐指数
1
解决办法
3847
查看次数