How do you get access to the asset_url
or asset_path
Sprockets URL helpers inside a Rake task?
I have a Rake task that seeds the database with some models. One of the models has the URL to an asset in the Rails app. How do I create a URL for this asset while inside the Rake task?
SomeModel.create(image: asset_url('awesome.png'))
For now I have a really poor solution to the issue.
path = URI.join(Rails.application.routes.url_helpers.root_url, '/assets/images/awesome.png')
SomeModel.create(image: path.to_s)