【发布时间】:2016-03-22 09:12:10
【问题描述】:
对 Rails 还很陌生,似乎无法让这个简单的破坏动作发挥作用。它所做的只是重定向到模组面板索引页面并且不会破坏记录。我需要在destroy方法中调用.destroy吗?还是我缺少什么?
mod_approval 控制器
def index
@guide = Guide.friendly.find(params[:guide_id])
@check_category = CheckCategory.where(guide_id: @guide.id).all
@category = Guide.friendly.find(@guide.id).categories.new
end
def destroy
redirect_to guide_mod_panel_mod_approval_index_path(@guide)
end
config/routes.rb
match '/guides/:guide_id/mod-panel/approve/reject' => 'mod_approval#destroy', :via => :delete, as: :guide_mod_panel_approve_destroy
index.html.erb
<% @check_category.each do |category| %>
<%= link_to "Reject", guide_mod_panel_approve_destroy_path(@guide, category), method: :delete, data: {confirm: "You sure?"} %><br>
<% end %>
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4