From 2143122a303e610cdce79d370a7bf4bbb7f20daf Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 18 Jun 2020 12:28:04 +0200 Subject: [PATCH] Add helper method for correctly generating with fingerprints in Serializers --- app/helpers/serializer_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/helpers/serializer_helper.rb b/app/helpers/serializer_helper.rb index f30d998f73..091c93d145 100644 --- a/app/helpers/serializer_helper.rb +++ b/app/helpers/serializer_helper.rb @@ -13,4 +13,11 @@ module SerializerHelper (serializer_attributes & model_attributes).map { |attr| "#{model.table_name}.#{attr}" } end + + # Since Rails 4 has adjusted the way assets paths are handled, we have to access certain + # asset-based helpers like this, when outside of a view or controller context. + # See: https://stackoverflow.com/a/16609815 + def image_path(path) + ActionController::Base.helpers.image_path(path) + end end