I'm using AssetPack to handle public assets on my Sinatra app. Because the app work as a embeddeable ad on sites, I need to declare css assets route absolute. This is my current code:
require 'rubygems'
require 'sinatra'
require 'rack'
require 'sinatra/assetpack'
class Ads < Sinatra::Application
assets {
css :mybanner, "http://#{request.host_with_port}/css/styling.css", [
"http://#{request.host_with_port}/css/styling.css"
]
}
The problem is that when calling request.host_with_port
I'm getting the following error
NameError: undefined local variable or method `request' for # <Sinatra::AssetPack::Options:0x007fc1f88b0a80>
I'm not sure why request
is not working. Any idea?