diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 105000495..f2b4f1138 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -268,6 +268,8 @@ class FilesController < ApplicationController else sort = "#{Attachment.table_name}.created_on desc" end + # @containers = [ Project.includes(:attachments).find(@project.id)] + # @containers += @project.versions.includes(:attachments).all @containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)] diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c8fe0811e..d90b0368e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -618,7 +618,7 @@ class Attachment < ActiveRecord::Base end end def update_attachment_ealasticsearch_index - if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || + if self.is_public == 1 && ( ((self.container_type == 'Project' or self.container_type == 'Version') && Project.find(self.container_id).is_public == 1) || ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || self.container_type == 'Principal') begin diff --git a/db/migrate/20160108021447_change_attachment_history.rb b/db/migrate/20160108021447_change_attachment_history.rb new file mode 100644 index 000000000..f217e595a --- /dev/null +++ b/db/migrate/20160108021447_change_attachment_history.rb @@ -0,0 +1,11 @@ +class ChangeAttachmentHistory < ActiveRecord::Migration + def up + attachments = Attachment.where("container_type =?", "Version") + attachments.each do |am| + am.update_attribute(:container_type, "Project") unless am.nil? + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index a3297de97..641f9c75c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160105073350) do +ActiveRecord::Schema.define(:version => 20160108021447) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false