Cannot locate assets after changing base url with map (Rails)

778 Views Asked by At

Please refer to the original question Changing the base URL for Rails 3 development. My application has to run at /a/special/route in relation to the host. I used the map solution, which works for the view.

In config.ru:

map '/mydepartment' do
  run Myapp::Application
end

(The scope answer doesn't work. I get undefined method scope for Main Object)

But the assets are not resolved like the comments indicate. I tried using a bunch of different prefix to no avail: 1. config.assets.prefix = '/a/special/route/assets'

ActionController::RoutingError (No route matches [GET] "/assets/application.js"): 
  1. config.assets.prefix = '/a/special/route/'

    ActionController::RoutingError (No route matches [GET] "/paginate.js")

  2. Using scope:

    scope '/a/special/route/' do

    resources :channels

    end

undefined method 'scope' for main:Object (NoMethodError)

Does anyone have a clue?

1

There are 1 best solutions below

0
On

@tagCincy No I didn't. So when I do use scope correctly inside Rails.application.routes.draw, the app can't find any template....

Anyway my assets problem seems to be more complicated than I thought. We use Varnish to serve the app at another-hostname.com/a/special/route. And the requests for assets are made relative to another-hostname.com/assets/ while they are located in actual-hostname.com/assets/. So I used this in application.rb as a hack fix: config.action_controller.asset_host = "actual-hostname.com"