diff --git a/app/controllers/tpi/home_controller.rb b/app/controllers/tpi/home_controller.rb index 67feee9a2..84dd48c51 100644 --- a/app/controllers/tpi/home_controller.rb +++ b/app/controllers/tpi/home_controller.rb @@ -2,7 +2,7 @@ module TPI class HomeController < TPIController def index @case_studies = CaseStudy.all - @sector_clusters = TPISectorCluster.all.group_by(&:slug).transform_values(&:first) + @sector_clusters = TPISectorCluster.includes(:sectors).group_by(&:slug).transform_values(&:first) page = TPIPage.find_by(slug: 'homepage-content') @home_content = { @@ -29,7 +29,7 @@ def index } @latest_researches = Publication .published - .includes([:image_attachment, :author_image_attachment]) + .includes([image_attachment: :blob, author_image_attachment: :blob, file_attachment: :blob]) .order(publication_date: :desc) .take(3) diff --git a/app/helpers/file_helper.rb b/app/helpers/file_helper.rb index bd985ae8b..ba3cb8d35 100644 --- a/app/helpers/file_helper.rb +++ b/app/helpers/file_helper.rb @@ -5,4 +5,8 @@ def preview_file_tag(file, options = {}) link_to "Uploaded file: #{file.blob.filename}", rails_blob_path(file), options.merge(target: '_blank') end + + def format_of(file) + Mime::Type.lookup(file.content_type).symbol + end end diff --git a/app/models/bank_assessment.rb b/app/models/bank_assessment.rb index 329f179dd..1aec7d95f 100644 --- a/app/models/bank_assessment.rb +++ b/app/models/bank_assessment.rb @@ -11,7 +11,7 @@ # class BankAssessment < ApplicationRecord belongs_to :bank - has_many :results, class_name: 'BankAssessmentResult' + has_many :results, class_name: 'BankAssessmentResult', dependent: :destroy validates_presence_of :assessment_date validates :assessment_date, date_after: Date.new(2010, 12, 31) diff --git a/app/views/tpi/home/index.html.erb b/app/views/tpi/home/index.html.erb index 493feb070..f9929994f 100644 --- a/app/views/tpi/home/index.html.erb +++ b/app/views/tpi/home/index.html.erb @@ -144,7 +144,7 @@