Forum: Ruby on Rails RAILS_ROOT Help Required!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A9e3c4a01eb6d20574312fee4cdf656c?d=identicon&s=25 Rizwan Reza (hrrzone)
on 2006-03-25 10:04
Hi,

I am new over here and also a newbie for Ruby on Rails. I am working on
a simple webapp for my band work. I have created a upload
controller/model and database which allows to save my files in the
directory at /public/dump/. Uploading works but I can't retrieve it.

I have tried several ways. The model uses DUMP_PATH = RAILS_ROOT +
"/public/dump" to save the file. But when I use it in view as:

<%= link_to upload.filename, :action => RAILS_ROOT + "/public/dump/" +
upload.filename %>

It doesn't retrieve. I can't access to the file even by using absolute
paths. The HTML output is:

<a
href="/upload/%2FUsers%2Frizwanreza%2Frails_projects%2Fbandwork%2Fpublic%2F..%2Fconfig%2F..%2Fpublic%2Fdump%2FDM100044.WMA">DM100044.WMA</a>

I don't what's wrong. As I said, the absolute paths don't work as well.

Thanks in advance. I have made the above possible by following this:
http://www.albert.bagasie.com/RailsTips/FileUpload

Regards,

Rizwan Reza
9c0eebc506c56c64dc616cdf123fa671?d=identicon&s=25 Chris Chris (aboulafia)
on 2006-03-25 10:14
Because when you want an hyperlink to the file you don't have to use
RAILS_ROOT : this will produce an absolute, filesystem related pathname.
What you want is a relative path for public access which should be
"/public/dump/" + upload.filename
A9e3c4a01eb6d20574312fee4cdf656c?d=identicon&s=25 Rizwan Reza (hrrzone)
on 2006-03-25 11:10
Christophe Gimenez wrote:
> Because when you want an hyperlink to the file you don't have to use
> RAILS_ROOT : this will produce an absolute, filesystem related pathname.
> What you want is a relative path for public access which should be
> "/public/dump/" + upload.filename

Thanks for the reply. This worked: <a href="/dump/<%= upload.filename
%>"><%= upload.filename %></a>

Thank you very much.

Rizwan
9c0eebc506c56c64dc616cdf123fa671?d=identicon&s=25 Chris Chris (aboulafia)
on 2006-03-25 11:21
Rizwan Reza wrote:
>
> Thanks for the reply. This worked: <a href="/dump/<%= upload.filename
> %>"><%= upload.filename %></a>
>

You're welcome, and of course the right setting is without /public -
Forgive me I'm awakening ;-)
This topic is locked and can not be replied to.