我想从我的数据库中删除一些东西.该值引用其他一些表.
错误是:
Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails
Run Code Online (Sandbox Code Playgroud)
我该如何正确解决这个问题?
如果我添加一些像删除级联一样的约束,其他值将不会被删除吗?
编辑:
def delete
@vid = Movie.find params[:id]
@vid.delete
redirect_to :action => :add
end
Run Code Online (Sandbox Code Playgroud)
更新模型
movie.rb
class Movie < ActiveRecord::Base
has_many :comments, :dependent => :destroy
has_many :ratings
belongs_to :channel
has_and_belongs_to_many :tags
has_and_belongs_to_many :categories
mount_uploader :video, MovieUploader
Run Code Online (Sandbox Code Playgroud)
comment.rb
class Comment < ActiveRecord::Base
belongs_to :movie
belongs_to :user
belongs_to :rating
Run Code Online (Sandbox Code Playgroud) 使用模板 angular 运行应用程序 dotnet-core 时遇到问题,出现此错误:
Browserslist: caniuse-lite is outdated. Please run the following command: `npm update`fail: Microsoft.AspNetCore.SpaServices[0]
Browserslist: caniuse-lite is outdated. Please run the following command: `npm update`
Run Code Online (Sandbox Code Playgroud)
我尝试运行,npm update但它不起作用,并且在运行该命令时没有收到任何消息。
所有版本
Angular CLI: 10.0.5
Node: 14.4.0
DotNet: 3.1.201
Run Code Online (Sandbox Code Playgroud)
包版本:
我怎样才能解决这个问题?谢谢