Relative Path in a Rails Application

0 views
Skip to first unread message

Sean Carey

unread,
May 13, 2008, 3:31:21 PM5/13/08
to boston-r...@googlegroups.com
I have run into a small snag, and a fear that it may be a simple question, but we will see. 

My Environment: 

nginx/mongrel/rails


Most people I know use a ROOT app for their rails application, but I would like my app to sit under a relative path. The reason I want a relative path is that we will have many rails apps, and I want to Layer7/Proxy to backend servers, and not have virtual hosts for each app. 

ie: 

www.myapp.com/tj/   --> would proxy to one server
www.myapp.com/tk/  --> would proxy to another server


Now this works all fine and good except rails cannot find the route: 

/tj/
/tk/


This is the error that I am getting: 

ActionController::RoutingError (No route matches "/tj/" with {:method=>:get}):
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
 


So, my question: 

How do I set this relative path in my rails application?

I tried:

environment.rb
RAILS_RELATIVE_URL_ROOT='/tj/'


This did not help. Any advice would be great. 


/sc 

Tyler McMullen

unread,
May 13, 2008, 3:44:21 PM5/13/08
to boston-r...@googlegroups.com
Assuming you're using mongrel_cluster... You can add the following to it:

prefix: /tj

Hope that helps.


-- Tyler

Vikram B.Kumar

unread,
May 13, 2008, 3:48:27 PM5/13/08
to boston-r...@googlegroups.com

You can also try setting the PATH_PREFIX in environment.rb or setting :path_prefix in route.rb.

 

More information at http://wiki.rubyonrails.org/rails/pages/HowToInstallApplicationsInSubdirectories

 

If you do so, stick to the link/url generators instead of hardcoding them in your templates.

 

Vikram

Sean Carey

unread,
May 13, 2008, 4:04:46 PM5/13/08
to boston-r...@googlegroups.com
Prefix in mongrel_cluster worked. Thanks so much!

/sc



Sean Carey 
Systems Architect

skype: densone
aim:      rlnux

Reply all
Reply to author
Forward
0 new messages