diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index 79945b6f..362a5f46 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -10,7 +10,7 @@ module TopicsHelper topic['value'] = t.name topic['description'] = t.desc.truncate(70) # make this return matched results topic['type'] = t.metacode.name - topic['typeImageURL'] = asset_path(t.metacode.icon) + topic['typeImageURL'] = t.metacode.asset_path_icon topic['permission'] = t.permission topic['mapCount'] = t.maps.count topic['synapseCount'] = t.synapses.count diff --git a/app/models/metacode.rb b/app/models/metacode.rb index 5f83cb91..a1184e9c 100644 --- a/app/models/metacode.rb +++ b/app/models/metacode.rb @@ -15,15 +15,17 @@ class Metacode < ActiveRecord::Base end def asset_path_icon - ActionController::Base.helpers.asset_path icon + if icon.start_with?('http') + icon + else + ActionController::Base.helpers.asset_path icon + end end #output json with asset_paths merged in def as_json(options) json = super(options.merge!(methods: :asset_path_icon)) - unless json["icon"].start_with?('http') - json["icon"] = json["asset_path_icon"] - end + json["icon"] = json["asset_path_icon"] json.except("asset_path_icon") end end