diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb
index c0e6725..21ec472 100644
--- a/app/controllers/glossary_terms_controller.rb
+++ b/app/controllers/glossary_terms_controller.rb
@@ -1,6 +1,6 @@
class GlossaryTermsController < ApplicationController
- before_action :find_term_from_id, only: [:show]
+ before_action :find_term_from_id, only: [:show, :edit, :update]
def index
@glossary_terms = GlossaryTerm.all
@@ -14,9 +14,22 @@ class GlossaryTermsController < ApplicationController
term = GlossaryTerm.new(glossary_term_params)
if term.save
flash[:notice] = l(:notice_successful_create)
- redirect_to glossary_term_path(term.id)
+ redirect_to term
end
end
+
+ def edit
+ end
+
+ def update
+ @term.attributes = glossary_term_params
+ if @term.save
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to @term
+ end
+ rescue ActiveRecord::StaleObjectError
+ flash.now[:error] = l(:notice_locking_conflict)
+ end
# Find the term whose id is the :id parameter
def find_term_from_id
diff --git a/app/views/glossary_terms/edit.html.erb b/app/views/glossary_terms/edit.html.erb
new file mode 100644
index 0000000..909e99f
--- /dev/null
+++ b/app/views/glossary_terms/edit.html.erb
@@ -0,0 +1,7 @@
+
<%=l :label_glossary_term %> #<%= @term.id %>
+
+<%= labelled_form_for :glossary_term, @term, url: glossary_term_path do |f| %>
+ <%= render partial: 'glossary_terms/form', locals: {form: f} %>
+ <%= f.submit l(:button_edit) %>
+<% end %>
+
diff --git a/app/views/glossary_terms/index.html.erb b/app/views/glossary_terms/index.html.erb
index cee5f2e..69d96a2 100644
--- a/app/views/glossary_terms/index.html.erb
+++ b/app/views/glossary_terms/index.html.erb
@@ -1,5 +1,9 @@
<%=l :label_glossary_terms %>
+
+ <%= link_to l(:label_glossary_term_new), new_glossary_term_path, class: 'icon icon-add' %>
+
+
diff --git a/app/views/glossary_terms/show.html.erb b/app/views/glossary_terms/show.html.erb
index 56cf6ea..7fc0140 100644
--- a/app/views/glossary_terms/show.html.erb
+++ b/app/views/glossary_terms/show.html.erb
@@ -1,3 +1,7 @@
+
+ <%= link_to l(:button_edit), edit_glossary_term_path, class: 'icon icon-edit' %>
+
+
<%=l :label_glossary_term %> #<%= @term.id %>
<%= @term.name %>
diff --git a/config/routes.rb b/config/routes.rb
index d003913..6b54e98 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,5 +2,5 @@
# See: http://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
- resources :glossary_terms, only: [:index, :show, :new, :create]
+ resources :glossary_terms
end