リビジョン fe492e04
| app/controllers/glossary_terms_controller.rb | ||
|---|---|---|
|
|
||
|
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
|
||
| app/models/glossary_term.rb | ||
|---|---|---|
|
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)}%"
|
||
|
}
|
||
| app/views/glossary_terms/_form.html.erb | ||
|---|---|---|
|
<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>
|
||
|
|
||
| app/views/glossary_terms/show.html.erb | ||
|---|---|---|
|
<td><%= format_time(@term.updated_at) %></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<%= render partial: 'attachments/links',
|
||
|
locals: {attachments: @term.attachments,
|
||
|
options: {deletable: User.current.logged?}
|
||
|
}%>
|
||
[phase-11]add attachable, but have permission problem