Rails-嵌套对象删除
|
我想删除嵌套对象“ 0”,该对象由“ 1”拥有。在
user#show
页面中,出现与user
相关的所有books
。除了每本书之外,还有指向“ 5”的链接。这是我的代码:
routes.rb
:
resources :users do
resources :books, :only => [:new, :create, :destroy]
end
book_controller.rb
:
def destroy
@user= User.find(params[:user])
@book = Book.find(params[:book])
@book.destroy
redirect_to current_user
end
在user#show
页面中:
<%= link_to \"Delete\", user_book_path(current_user, book), :method => :delete %>
我知道这是错误的,但是如何删除想要的书呢?
没有找到相关结果
已邀请:
1 个回复
细屠截殴些
书本控制器:
视图: