# Application URL prefixes in the File Column plug-in

**URL:** <https://www.ruby-forum.com/t/application-url-prefixes-in-the-file-column-plug-in/149125>\
**Category:** Rails\
**Created:** [September 21, 2008, 1:44am UTC](https://www.ruby-forum.com/t/application-url-prefixes-in-the-file-column-plug-in/149125 "2008-09-21T01:44:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dschruth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@dschruth](https://www.ruby-forum.com/u/dschruth)\
**Post date:** [September 21, 2008, 1:44am UTC](https://www.ruby-forum.com/t/application-url-prefixes-in-the-file-column-plug-in/149125/1 "2008-09-21T01:44:05Z")

</div>

I love this plugin (I’m able to get it working mostly) but I’m running  
into an issue with using it in an application with an mongrel/apache  
specified application level URL prefix. This is a problem for both  
uploading and viewing the file once it has been loaded. I was able to  
(manually or via 2b below) load it but then the hyperlink File Column  
created was still missing the prefix. It generated the following URL:

[http://mydomain.com/people/photo/4/picture.name.jpg](http://mydomain.com/people/photo/4/picture.name.jpg)  
instead of  
[http://mydomain.com/PREFIX/people/photo/4/picture.name.jpg](http://mydomain.com/PREFIX/people/photo/4/picture.name.jpg)

Is there an easy way to modify (a helper function? variables in  
environment.rb ?) code to get File Column to recognize the prefix? Is  
this a rail’s wide prefix that I could set?

Additionally I’m wishing that there were a way to define my prefix in  
just one place, currently, running a rails application in a  
subdirectory on the server requires no less than 3 modifications (for  
me):

1. 

ProxyPass /PREFIX [http://127.0.0.1:8000/PREFIX](http://127.0.0.1:8000/PREFIX) (in apache)

1. 

a)  
prefix: /PREFIX (in mongrel\_cluster.yml)  
OR  
b)  
ActionController::AbstractRequest.relative\_url\_root = “/PREFIX” (in  
environment.rb) PLUS symbolic links in my public folder

1. 

all of the hard coded links in my app/views/shared/\_header html file  
for example: [people](https://www.ruby-forum.com/PREFIX/people)

There has to be an easier, more elegant way. Anybody know of one?

Thanks,

Dave

---

<div class="post-metadata">

**Author:** ![dschruth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@dschruth](https://www.ruby-forum.com/u/dschruth)\
**Post date:** [September 21, 2008, 2:03am UTC](https://www.ruby-forum.com/t/application-url-prefixes-in-the-file-column-plug-in/149125/2 "2008-09-21T02:03:57Z")

</div>

I just realized that using rails’ relative\_url\_root (2b below) does  
fix problem 3 as well… and the public folder symbolic link work  
around  
(detailed here:  
[http://www.ralree.info/2006/6/15/successful-settings-for-apache-forwarding-to-mongrel](http://www.ralree.info/2006/6/15/successful-settings-for-apache-forwarding-to-mongrel))  
salvages half of file column’s functionality (namely: uploading).

But my main problem of _reading_ these uploaded files remains. The  
URL that File\_Column generates still doesn’t include the proper  
prefix.

Any ideas? Is there any easy way I can get File\_Column to use  
ActionController::AbstractRequest.relative\_url\_root that I set in  
environement.rb?

---

<div class="post-metadata">

**Author:** ![dschruth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@dschruth](https://www.ruby-forum.com/u/dschruth)\
**Post date:** [September 21, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/application-url-prefixes-in-the-file-column-plug-in/149125/3 "2008-09-21T17:21:48Z")

</div>

dschruth wrote:

> But my main problem of _reading_ these uploaded files remains. The  
> URL that File\_Column generates still doesn’t include the proper  
> prefix.
> 
> Any ideas? Is there any easy way I can get File\_Column to use  
> ActionController::AbstractRequest.relative\_url\_root that I set in  
> environement.rb?

Have you looked into File Column’s :base\_url option?

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)

---

<div class="post-metadata">

**Author:** ![dschruth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2acd7d/32.png) [@dschruth](https://www.ruby-forum.com/u/dschruth)\
**Post date:** [September 22, 2008, 12:23am UTC](https://www.ruby-forum.com/t/application-url-prefixes-in-the-file-column-plug-in/149125/4 "2008-09-22T00:23:45Z")

</div>

Ah ha,

## Yes, in file\_column.rb

# FileColumn’s storage location is determined in the following way.

All

# files are saved below the so-called “root\_path” directory, which

defaults to

# “RAILS\_ROOT/public”.
 # You can specify a custom root\_path by setting the :root\_path option.
# default options. You can override these with +file\_column+'s

+options+ parameter  
DEFAULT\_OPTIONS = {  
:root\_path =\> File.join(RAILS\_ROOT, “public”),  
:web\_root =\> “rails/”, #added “rails/” here

* * *

Thanks alot!

On Sep 21, 8:20 am, Mark Reginald J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
