[phase-4]add delete operation
This commit is contained in:
parent
fec83eefb5
commit
be33f1f6af
@ -1,6 +1,6 @@
|
|||||||
class GlossaryTermsController < ApplicationController
|
class GlossaryTermsController < ApplicationController
|
||||||
|
|
||||||
before_action :find_term_from_id, only: [:show, :edit, :update]
|
before_action :find_term_from_id, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@glossary_terms = GlossaryTerm.all
|
@glossary_terms = GlossaryTerm.all
|
||||||
@ -30,6 +30,11 @@ class GlossaryTermsController < ApplicationController
|
|||||||
rescue ActiveRecord::StaleObjectError
|
rescue ActiveRecord::StaleObjectError
|
||||||
flash.now[:error] = l(:notice_locking_conflict)
|
flash.now[:error] = l(:notice_locking_conflict)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@term.destroy
|
||||||
|
redirect_to glossary_terms_path
|
||||||
|
end
|
||||||
|
|
||||||
# Find the term whose id is the :id parameter
|
# Find the term whose id is the :id parameter
|
||||||
def find_term_from_id
|
def find_term_from_id
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<%= link_to l(:button_edit), edit_glossary_term_path, class: 'icon icon-edit' %>
|
<%= link_to l(:button_edit), edit_glossary_term_path, class: 'icon icon-edit' %>
|
||||||
|
<%= link_to l(:button_delete), glossary_term_path, method: :delete,
|
||||||
|
data: {confirm: l(:text_are_you_sure)}, class: 'icon icon-del' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2><%=l :label_glossary_term %> #<%= @term.id %></h2>
|
<h2><%=l :label_glossary_term %> #<%= @term.id %></h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user