Rails Protips Volume 1 - asset_url
Jan 15
Using asset_url helper outside of views.
If you get the error NoMethodError: undefined method `protocol' for nil:NilClass
while using ActionController::Base.helpers.asset_url(IMAGE_NAME)
somewhere other than a view, change it to ActionController::Base.helpers.asset_path(IMAGE_NAME)
. This is [probably] because your model doesn't have access to the request to figure out the protocol.