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!

3
  • Have you modified the routes ? Check via 'rake routes' to see what differences may exist Feb 19, 2010 at 5:31
  • I don't quite understand? What am I looking for in rake routes?
    – Joan Smith
    Feb 19, 2010 at 5:45
  • Can you provide the link to your source code? Feb 19, 2010 at 6:48

2 Answers 2

1

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'].

0
  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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.