我是 ROR 的新手,我正在尝试创建一个操作,我可以从中删除数据库中的文件。我已经为相同的代码编写了一个代码,但对 url 给出了错误。查看删除操作:-
= link_to raw('<span>Delete</span>'), :method=> :delete, destroy_attachment_path(attachment.descendants.last),
:data => { :confirm => 'Are you sure? This will permanently delete this file!' },
:remote => true,
:class => 'deleteShow deleteFile'
相同的控制器:-
enter code here
def destroy
@attachment = Attachment.find(params[:id])
@attachment.destroy
respond_to do |format|
format.html { redirect_to attachments_url }
format.json { head :no_content }
end
end
当我尝试运行此代码时,错误显示为无效方法 Destroy_attachment 路径。任何人都可以帮我解决问题吗?提前致谢。