From dd8574b8c35defa9e7065f0cadbd4e67e207b91d Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 1 May 2015 16:48:49 +0800 Subject: [PATCH] language stuff fixed --- app/controllers/archives_controller.rb | 22 +++++++++++-------- app/models/archive_file_multiple.rb | 2 +- .../admin/archive_files/_form_file.html.erb | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb index 10b8ae7..f846234 100644 --- a/app/controllers/archives_controller.rb +++ b/app/controllers/archives_controller.rb @@ -19,15 +19,19 @@ class ArchivesController < ApplicationController "status-class" => "status-#{status['classname']}" } end - files = archive.archive_file_multiples.order_by(:sort_number=>'asc').collect do |file| - title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue "" - extension = file.file.file.extension.downcase rescue "" - # url = file.file.url rescue "" - { - "file-name" => title, - "file-type" => extension, - "file-url" => "/xhr/archive/download?file=#{file.id}" - } + files = [] + archive.archive_file_multiples.order_by(:sort_number=>'asc').each do |file| + if file.choose_lang.include?(I18n.locale.to_s) + title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue "" + extension = file.file.file.extension.downcase rescue "" + # url = file.file.url rescue "" + files << { + "file-name" => title, + "file-type" => extension, + "file-url" => "/xhr/archive/download?file=#{file.id}" + } + end + end { diff --git a/app/models/archive_file_multiple.rb b/app/models/archive_file_multiple.rb index a5d81a5..6310b4e 100644 --- a/app/models/archive_file_multiple.rb +++ b/app/models/archive_file_multiple.rb @@ -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 => nil + field :choose_lang, :type => Array, :default => ["en","zh_tw"] field :should_destroy, :type => Boolean field :sort_number, :type => Integer diff --git a/app/views/admin/archive_files/_form_file.html.erb b/app/views/admin/archive_files/_form_file.html.erb index 82ae0ee..3d17e85 100644 --- a/app/views/admin/archive_files/_form_file.html.erb +++ b/app/views/admin/archive_files/_form_file.html.erb @@ -41,7 +41,7 @@ <% @site_in_use_locales.each do |locale| %>