views:

322

answers:

2

Thanks in advance for the help.

I'm trying to get my rails app looking even passably nice for the first time, and I'm having a lot of trouble getting stylesheets working.

In my application.html.erb layout file, I have the line:

<%= stylesheet_link_tag 'application', 'formtastic', 'formtastic_changes', :cache => "base" %>

Which, I thought, was supposed to do all of the work. But when I load the page, the stylesheet doesn't load at all. After poking around a bit I found the problem, but don't have the foggiest idea how to fix it!

Instead of loading the stylesheet from localhost:3000/stylesheets/application.css

my browser is trying to load from localhost:3000/myApp/stylesheets/application.css

and can't find the sheet there (since it doesn't exist there..)

So, any ideas how I can fix this? And, more generally, why some paths end up looking like localhost:3000/myApp/page and some look like localhost:3000/page

Thanks again!

A: 
  1. Search your app config directory for mention of 'myApp'. There is something in there that is overriding default route or asset_dir behavior.
  2. try removing :cache => "base" as an argument. This concatinates and caches the stylesheets together (in production mode) and might be interfering.

In general, make sure you are always using helper functions to generate links and urls for your views. (link_to, url_for, form_for, link_to_remote, etc.) This should make urls consistent across the app.

Kevin
+1  A: 

Sounds like an issue with your relative url root variable. Check your app and see if you're setting ActionController::Base.relative_url_root or ENV['RAILS_RELATIVE_URL_ROOT'].

Mark Turner