Automatically setting the "ActionController::AbstractRequest.relative_url_root" in Rails

11 views
Skip to first unread message

ChrisR

unread,
Feb 14, 2008, 6:20:45 AM2/14/08
to SwitchPipe
Would it be possible for switchpipe to automatically add this line to
production.rb when running rails?

ActionController::AbstractRequest.relative_url_root = "/APPNAME"

This would mean I could change the name of the yml file without also
having to remember to go into the rails app and change
production.rb.

Keep up the good work with switchpipe. It really has helped me with
deploying my rails apps inside my organisation.

Thanks

Chris Richards

Peter Cooper

unread,
Feb 14, 2008, 12:10:32 PM2/14/08
to SwitchPipe
On Feb 14, 11:20 am, ChrisR <EvilGeen...@gmail.com> wrote:
> Would it be possible for switchpipe to automatically add this line to
> production.rb when running rails?
>
> ActionController::AbstractRequest.relative_url_root = "/APPNAME"
>
> This would mean I could change the name of the yml file without also
> having to remember to go into the rails app and change
> production.rb.

This might be something a plugin (one of the forthcoming features - a
plugin system!) could tackle, but currently there is no nice way of
doing this.

However, I had this problem early on myself during development but
realized that I'd not ever be using subdirectories because I'd either
be proxying through from Apache, which would then mean Rails
applications get it right without needing to specify a root, OR I'd be
using SwitchPipe's "Host" support and using special hostnames directly
without needing the directory suffix. Is there a reason why these
approaches aren't suitable for you?

I'm not asking merely to implicitly make you use those techniques, but
I'm genuinely interested if there is a reason or demand for this so I
can consider it :)

> Keep up the good work with switchpipe.  It really has helped me with
> deploying my rails apps inside my organisation.

Thanks for the support!

Cheers,
Pete

ChrisR

unread,
Feb 14, 2008, 6:45:16 PM2/14/08
to SwitchPipe
I currently run about 10-15 rails apps on one of my companys main
servers.

How do I use the HOSTS support at the company I work for? WOuld this
require adding the hostnames to the main DNS server? If so then the
hosts support is too much of a pain in the ass for me. Having the
apps at different subdirectories is very convenient for me and
wouldn't require me to speak to our SysAdmins, which I'd rather not
do.


Thanks
CHris

ChrisR

unread,
Feb 14, 2008, 6:50:14 PM2/14/08
to SwitchPipe
> "Would it be possible for switchpipe to automatically add this line to
> production.rb when running rails? "

If this support were to be added then it would be best if it could be
enabled without actually modifying any of my ruby files
(production.rb). Source code control wouldn't like it.

Peter Cooper

unread,
Feb 14, 2008, 7:57:50 PM2/14/08
to SwitchPipe
It depends who needs to use the apps. If adding entries to /etc/hosts
(or the Windows equivalent - c:\windows\system32\drivers\etc\hosts - I
think.. it's been a few years) will do, then that works a treat. I do
this myself for all of my own apps on my local machine. I can then use
URLs like: http://app1/ http://app2/ etc.. and it all just works. You
then just need to specify the hostnames in the config files for each
app in SwitchPipe.

If multiple people need to access the app and use the hostname, then
yes, you'd need to add the hostnames into the local zone.

I believe another solution might be to try Mongrel's "--prefix"
feature. You'd need to set up a manual cmd line in the app config, but
specifying --prefix and then the directory prefix should do the trick.
So instead of type: mongrel_rails, you'd have something like:

mongrel_rails start -p [[PORT]] -e production --prefix app1 (or
possibly /app1/ or app1/ - I haven't tried it).

Pete

ChrisR

unread,
Feb 18, 2008, 8:13:02 AM2/18/08
to SwitchPipe
Pete,

i tried using this in the yml like you said :

cmd: "mongrel_rails start -p [[PORT]] -e production --prefix /tph"

This would be the ideal solution to my problem.
Unfortunately it doesn't work with switchpipe. The notation is correct
as I have tried it on its own. Switchpipe appears to instantiate it
correctly too, according to the logs :

"mongrel_rails start -p 60401 -e production --prefix /tph"


Thanks
Chris

Peter Cooper

unread,
Feb 21, 2008, 12:36:21 PM2/21/08
to SwitchPipe
On Feb 18, 1:13 pm, ChrisR <EvilGeen...@gmail.com> wrote:
> This would be the ideal solution to my problem.
> Unfortunately it doesn't work with switchpipe. The notation is correct
> as I have tried it on its own.   Switchpipe appears to instantiate it
> correctly too, according to the logs :
>
> "mongrel_rails start -p 60401 -e production --prefix /tph"

Rather odd! I will give it a go myself, but before I do, have you
tried it in a different location? For example:

mongrel_rails start --prefix /tph -p [[PORT]] -e production

I'd be intrigued to see if perhaps there's some weird limit in the
libraries I'm using to launch the processes that might be cutting
stuff off. The -e production part is the least important in terms of
testing, so if this works, it might give us some clues..

Pete
Reply all
Reply to author
Forward
0 new messages