Force absolute URLs in views throughout a response
This is more tricky than it should be because url_for, asset_path, etc. all rely on different mechanisms.
Anyway, you can use the attached trait like this:
class ExampleController < ApplicationController
does 'host_enforcement', :for => 'some_action'
end
Short explanation:
-
asset_hostis used for links to stylesheets and javascripts -
asset_hostbelongs toActionController::Base-- changes are persistent and will not be reset after a request -
rewrite_optionsis used by the..._pathmethods in the views
^...