Rails发布删除功能,给出模板错误

时间:2013-10-09 10:59:29

标签: ruby-on-rails ruby-on-rails-4

我正在尝试从数据库中删除某个预订的链接。这是我的解决方案,但它一直给出模板错误。它不应该呈现视图,但它是。

def delete
  @current = Reservations.find(params['reservations']['id'])
  respond_to do |format|
    if current_user

        if @current.user_id == current_user.id
            @current.destroy
            format.html { redirect_to :back }
        else
            format.html { redirect_to root_path }
        end
    else
        format.html { redirect_to root_path }
    end
  end
end

我的路线档案

post "reservations/delete", to: 'reservations#delete', as: 'delete_reservation'

我的观点包括删除链接:

<%= form_for item, :url => {:controller => 'reservations', :action => 'delete'}, :method => 'post' do |f| %>

  <%= f.hidden_field :id, :value => item.id %>

  <%= f.submit "Delete", :class =>'btn btn-danger btn-small' %>

<% end %>

0 个答案:

没有答案