diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index 6cac4f9..8f96902 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -30,6 +30,8 @@ class GlossaryTermsController < ApplicationController def update @term.attributes = glossary_term_params + @term.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@term) if @term.save redirect_to [@project, @term], notice: l(:notice_successful_update) end diff --git a/app/models/glossary_term.rb b/app/models/glossary_term.rb index f044385..d0d4a25 100644 --- a/app/models/glossary_term.rb +++ b/app/models/glossary_term.rb @@ -2,6 +2,9 @@ class GlossaryTerm < ActiveRecord::Base belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id' belongs_to :project + # class method from Redmine::Acts::Attachable::ClassMethods + acts_as_attachable + scope :search_by_name, -> (keyword) { where 'name like ?', "#{sanitize_sql_like(keyword)}%" } diff --git a/app/views/glossary_terms/_form.html.erb b/app/views/glossary_terms/_form.html.erb index 2bf6b15..2aa816b 100644 --- a/app/views/glossary_terms/_form.html.erb +++ b/app/views/glossary_terms/_form.html.erb @@ -8,3 +8,11 @@

<%= form.select :category_id, GlossaryCategory.pluck(:name, :id), include_blank: true %>

<%= form.text_area :description, size: "80x10", required: false %>

+ +
+

+ + <%= render partial: 'attachments/form' %> +

+
+ diff --git a/app/views/glossary_terms/show.html.erb b/app/views/glossary_terms/show.html.erb index 2aeb992..e1a2b2b 100644 --- a/app/views/glossary_terms/show.html.erb +++ b/app/views/glossary_terms/show.html.erb @@ -52,3 +52,8 @@ <%= format_time(@term.updated_at) %> + +<%= render partial: 'attachments/links', +locals: {attachments: @term.attachments, + options: {deletable: User.current.logged?} +}%>