[phase-11]add attachable, but have permission problem

This commit is contained in:
Toru Takahashi 2018-06-08 20:57:51 +09:00 committed by TAKAHASHI,Toru
parent f78775ac43
commit fe492e0488
4 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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)}%"
}

View File

@ -8,3 +8,11 @@
<p><%= form.select :category_id, GlossaryCategory.pluck(:name, :id), include_blank: true %></p>
<p><%= form.text_area :description, size: "80x10", required: false %></p>
</div>
<div class="box">
<p>
<label><%=l :label_attachment_plural %></label>
<%= render partial: 'attachments/form' %>
</p>
</div>

View File

@ -52,3 +52,8 @@
<td><%= format_time(@term.updated_at) %></td>
</tr>
</table>
<%= render partial: 'attachments/links',
locals: {attachments: @term.attachments,
options: {deletable: User.current.logged?}
}%>