I seem to be misunderstanding something very basic in trying to run my
app in a subdirectory.  Remarkably, all my restful routes work
flawlessly.  Everything outside of rails routing conventions is what's
giving me problems.  My app is using mod_rails and I've got it sym-
linked to www.domain.com/myapp (for example).

My application layout includes this line in the head section of the
html:

<link rel="shortcut icon" type="image/ico" href="/favicon.ico" />

And of course that doesn't work...it can't find my app's favicon,
instead pointing to the root of my domain to look for it.  Basically,
you can't reference anything with a leading slash if you're running
the app in a subdirectory.  Manual routing like this needs to know the
"url root", I'm thinking.  So I found this setting:

config.action_controller.relative_url_root

Rails guides says that it can be used to tell Rails that you are
deploying to a subdirectory. The default is ENV
['RAILS_RELATIVE_URL_ROOT'].  Ok, so I added that config setting to my
config/environment.rb and nothing changed.  What exactly does this
action_controller setting do and how do you use it?

The other thing I tried (which worked but it's ugly) was to set the
RAILS_RELATIVE_URL_ROOT env variable in config/environment.rb to my
app's root (/myapp):

RAILS_RELATIVE_URL_ROOT = '/myapp'

Then in my application layout, I accessed the app's favicon like this:

<link rel="shortcut icon" type="image/ico" href="<
%=RAILS_RELATIVE_URL_ROOT%>/favicon.ico" />

And same thing with an image:

<img src="<%=RAILS_RELATIVE_URL_ROOT%>/images/avatar.gif" alt=""
style="border: 1px solid #ddd; padding: 3px; margin: 0 10px 0 0;"/>

So everywhere I need to reference a path outside of rails' named
routes, I have to insert this env variable?  That can't be best
practice!   Or is it?

Thanks for any help!
-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to