Question

I'm trying to convert a Rails 3.1 app to use the asset pipeline. Currently using Rails 3.2.0.rc2. I'm setting ENV['RAILS_RELATIVE_URL_ROOT'] to the suburi in application.rb. The helpers work fine, generating the correct path (including the suburi) to the file, however Rails routes aren't serving the files off of that path.

For instance, <%= stylesheet_link_tag 'screen', :media => 'screen' %> correctly generates the code <link href="/my-suburi/assets/screen.css" media="screen" rel="stylesheet" type="text/css" />, however Rails won't serve anything off of this address.

If I manually point my browser at http://localhost:3000/my-suburi/assets/screen.css I get a ActionController::RoutingError. However, if I point it at http://localhost:3000/assets/screen.css I get the file. Everything else works fine with the sub-uris.

Anybody have any idea what I might be missing? Thanks.

Was it helpful?

Solution

Figured it out myself. In application.rb, I added...

config.assets.prefix = "/my-suburi"

and then restarted the server. That changed the path in the header to be "/my-suburi/screen.css" (notice the lack of 'assets'), but I confirmed that it is correctly pulling from the /app/assets/stylesheets folder, now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top