Fix bug.
This commit is contained in:
parent
303f431aa7
commit
86926da612
|
@ -217,8 +217,7 @@ class ArchivesController < ApplicationController
|
|||
file_id = params[:file]
|
||||
file = ArchiveFileMultiple.find(file_id) rescue nil
|
||||
if !file.nil? && file.file.present?
|
||||
file.download_count = file.download_count + 1
|
||||
file.save
|
||||
file.inc(download_count: 1)
|
||||
@url = file.file.url
|
||||
begin
|
||||
@path = file.file.file.file rescue ""
|
||||
|
|
|
@ -8,7 +8,7 @@ class ArchiveFileMultiple
|
|||
field :file_title, localize: true
|
||||
# field :description
|
||||
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 :sort_number, :type => Integer
|
||||
|
@ -19,7 +19,7 @@ class ArchiveFileMultiple
|
|||
self.choose_lang.include?(lang)
|
||||
end
|
||||
|
||||
belongs_to :archive_file
|
||||
belongs_to :archive_file, index: true
|
||||
|
||||
# has_many :archive_file_multiple_langs, :autosave => true, :dependent => :destroy
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
<% @site_in_use_locales.each do |locale| %>
|
||||
<li>
|
||||
<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) %>
|
||||
</label>
|
||||
</li>
|
||||
<% end %>
|
||||
</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>
|
||||
|
||||
<% if form_file.new_record? %>
|
||||
|
|
Loading…
Reference in New Issue