diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index ae43e65..05c3edc 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -1,7 +1,7 @@ class GlossaryTermsController < ApplicationController before_action :find_term_from_id, only: [:show, :edit, :update, :destroy] - before_action :find_project_from_id, only: [:index, :create] + before_action :find_project_from_id def index @glossary_terms = GlossaryTerm.where(project_id: @project.id) @@ -15,7 +15,7 @@ class GlossaryTermsController < ApplicationController term = GlossaryTerm.new(glossary_term_params) term.project = @project if term.save - redirect_to term, notice: l(:notice_successful_create) + redirect_to [@project, term], notice: l(:notice_successful_create) end end @@ -25,16 +25,15 @@ class GlossaryTermsController < ApplicationController def update @term.attributes = glossary_term_params if @term.save - redirect_to @term, notice: l(:notice_successful_update) + redirect_to [@project, @term], notice: l(:notice_successful_update) end rescue ActiveRecord::StaleObjectError flash.now[:error] = l(:notice_locking_conflict) end def destroy - project = @term.project @term.destroy - redirect_to project.nil? ? home_path : project_glossary_terms_path(project) + redirect_to project_glossary_terms_path end # Find the term whose id is the :id parameter diff --git a/app/views/glossary_terms/edit.html.erb b/app/views/glossary_terms/edit.html.erb index 909e99f..6c45c2a 100644 --- a/app/views/glossary_terms/edit.html.erb +++ b/app/views/glossary_terms/edit.html.erb @@ -1,6 +1,6 @@

<%=l :label_glossary_term %> #<%= @term.id %>

-<%= labelled_form_for :glossary_term, @term, url: glossary_term_path do |f| %> +<%= labelled_form_for :glossary_term, @term, url: project_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 1ee4032..65dea9b 100644 --- a/app/views/glossary_terms/index.html.erb +++ b/app/views/glossary_terms/index.html.erb @@ -20,7 +20,7 @@ <%= term.id %> - <%= link_to term.name, term %> + <%= link_to term.name, [@project, term] %> <%= term.category.try!(:name) %> diff --git a/app/views/glossary_terms/show.html.erb b/app/views/glossary_terms/show.html.erb index e7a805a..44f7624 100644 --- a/app/views/glossary_terms/show.html.erb +++ b/app/views/glossary_terms/show.html.erb @@ -1,6 +1,6 @@
- <%= link_to l(:button_edit), edit_glossary_term_path, class: 'icon icon-edit' %> - <%= link_to l(:button_delete), glossary_term_path, method: :delete, + <%= link_to l(:button_edit), edit_project_glossary_term_path, class: 'icon icon-edit' %> + <%= link_to l(:button_delete), project_glossary_term_path, method: :delete, data: {confirm: l(:text_are_you_sure)}, class: 'icon icon-del' %>
diff --git a/config/routes.rb b/config/routes.rb index e1b803f..ec2e56a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ # See: http://guides.rubyonrails.org/routing.html Rails.application.routes.draw do - resources :projects, shallow: true do + resources :projects do resources :glossary_terms end resources :glossary_categories