Wraps a Source using Rails’
AssetTagHelper#image_path
, which can turn path URLs (e.g.
‘/images/my_avatar.png’) into absolute URLs( e.g. ‘’).
Passes url
to AssetTagHelper#image_path
. Raises
an error if it cannot generate a fully-qualified URI. Try setting
ActionController::Base.asset_host
to avoid this error.
# File lib/avatar/source/wrapper/rails_asset_source_wrapper.rb, line 27 def wrap(url, person, options = {}) # url will never be nil b/c of guarantee in AbstractSourceWrapper result = url_helper.image_path(url) raise "could not generate protocol and host for #{url}. Have you set ActionController::Base.asset_host?" unless result =~ /^http[s]?\:\/\// result end
# File lib/avatar/source/wrapper/rails_asset_source_wrapper.rb, line 17 def initialize(source) super @url_helper = Object.new @url_helper.extend(ActionView::Helpers::AssetTagHelper) end