This commit is contained in:
邱博亞 2024-07-21 15:35:43 +08:00
parent 303f431aa7
commit 86926da612
3 changed files with 5 additions and 6 deletions

View File

@ -217,8 +217,7 @@ class ArchivesController < ApplicationController
file_id = params[:file] file_id = params[:file]
file = ArchiveFileMultiple.find(file_id) rescue nil file = ArchiveFileMultiple.find(file_id) rescue nil
if !file.nil? && file.file.present? if !file.nil? && file.file.present?
file.download_count = file.download_count + 1 file.inc(download_count: 1)
file.save
@url = file.file.url @url = file.file.url
begin begin
@path = file.file.file.file rescue "" @path = file.file.file.file rescue ""

View File

@ -8,7 +8,7 @@ class ArchiveFileMultiple
field :file_title, localize: true field :file_title, localize: true
# field :description # field :description
field :download_count, type: Integer, default: 0 field :download_count, type: Integer, default: 0
field :choose_lang, :type => Array, :default => ["en","zh_tw"] field :choose_lang, :type => Array, :default => I18n.available_locales.map{|l| l.to_s}
field :should_destroy, :type => Boolean field :should_destroy, :type => Boolean
field :sort_number, :type => Integer field :sort_number, :type => Integer
@ -19,7 +19,7 @@ class ArchiveFileMultiple
self.choose_lang.include?(lang) self.choose_lang.include?(lang)
end end
belongs_to :archive_file belongs_to :archive_file, index: true
# has_many :archive_file_multiple_langs, :autosave => true, :dependent => :destroy # has_many :archive_file_multiple_langs, :autosave => true, :dependent => :destroy

View File

@ -37,13 +37,13 @@
<% @site_in_use_locales.each do |locale| %> <% @site_in_use_locales.each do |locale| %>
<li> <li>
<label class="checkbox"> <label class="checkbox">
<%= check_box_tag "archive_file[archive_file_multiples_attributes][#{( form_file.new_record? ? 'new_archive_file_multiples' : "#{i}" )}][choose_lang][]", locale, form_file.choose_lang.include?(locale.to_s) %> <%= check_box_tag "#{f.object_name}[choose_lang][]", locale, form_file.choose_lang.include?(locale.to_s) %>
<%= t(locale.to_s) %> <%= t(locale.to_s) %>
</label> </label>
</li> </li>
<% end %> <% end %>
</ul> </ul>
<%= hidden_field_tag "archive_file[archive_file_multiples_attributes][#{( form_file.new_record? ? 'new_archive_file_multiples' : "#{i}" )}][choose_lang][]", '' %> <%= hidden_field_tag "#{f.object_name}[choose_lang][]", '' %>
</span> </span>
<% if form_file.new_record? %> <% if form_file.new_record? %>