0

プレゼンテーション ビルダーを作成していますが、[削除] ボタンをクリックしたときに、リストに表示されている選択したプレゼンテーションを破棄する方法がわかりません。

私のコントローラーは次のようになります。

  def create
    if logged_in?
      presentation = current_user.presentations.create data: params.to_yaml
      redirect_to edit_presentation_path(presentation)
    end
  end

  def edit
    render action: :new
  end

  # def destroy
  #   current_presentation.destroy
  # end

  def show
    render action: :new
  end

  def list
    @presentations = current_user.presentations
  end

  def update
    current_presentation.update_attributes(data: params.to_yaml)
  end

  def home
    if logged_in?
      @presentations = current_user.presentations
    end
  end

作成したプレゼンテーションのリストは次のようになります。

  <% @presentations.each do |p| %> 
      <a >  <%= p.id %>
        <a href="<%= presentation_path(p) %>" target="_blank" class="action"> Show </a> 
        <a class="action"> Remove </a>  
      </a>
   <% end %> 

私の目標は、正しい destroy メソッドを記述し、特定のプレゼンテーションに対してこのメ​​ソッドを実行するリンク Remove を作成することです。

4

2 に答える 2

1
<%= link_to "Delete", your_destroy_path(p), method: :delete %>
于 2013-10-24T16:18:18.167 に答える