Forum: Ruby on Rails How to link_to a file out side rails application

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.
7fbd0e99b27064b14793f028022974e5?d=identicon&s=25 Zhao Yi (youhaodeyi)
on 2009-01-22 02:33
I want to link to a file outside rails application. It is a text file
stored in rails server disk. When user click this link, the file will be
open.

How can I do this?

thanks.
247cd3d37084a3d6794076207bd9fbd7?d=identicon&s=25 Bobnation (Guest)
on 2009-01-22 05:44
(Received via mailing list)
That's a good question, and I'll let someone else handle it as I leave
work tonight.

However, I might recommend probably starting up one thread on the
mailing list and asking your questions in there. Will be easier to
keep track of them if they are all in one place. Thanks!
Dfe81d0ef18761dc22d0586b7b58c5ac?d=identicon&s=25 Rob Zolkos (rzolkos)
on 2009-01-22 06:21
(Received via mailing list)
Hi,

Try this :

<%= link_to "file", "http://www.mysite.com/the_file.doc" %>

Regards,
Rob
7fbd0e99b27064b14793f028022974e5?d=identicon&s=25 Zhao Yi (youhaodeyi)
on 2009-01-22 06:28
Rob Zolkos wrote:
> Hi,
>
> Try this :
>
> <%= link_to "file", "http://www.mysite.com/the_file.doc" %>
>
> Regards,
> Rob

My problem is that the file is not in Rails application. There is on
"http://" start. I just want to point to a local file in the server hard
disk. For example: <%= link_to "file", "/tmp/hello.txt" %>
F53e11a2500da29c1837c604bd0fb117?d=identicon&s=25 Manmay (Guest)
on 2009-01-22 06:34
(Received via mailing list)
hi Zhao,

u can use send_file to relate the file in u'r file system but not in
public dir of u'r rails proj like,

send_file(RAILS_ROOT+"/images_uploaded/"+params[:filename] ,
:disposition => 'inline')

-manmay



On Thu, Jan 22, 2009 at 10:58 AM, Zhao Yi
<rails-mailing-list@andreas-s.net> wrote:
>
> My problem is that the file is not in Rails application. There is on
> "http://" start. I just want to point to a local file in the server hard
> disk. For example: <%= link_to "file", "/tmp/hello.txt" %>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>



--
M@nmay
http://manmays.googlepages.com
http://manmays.blogspot.com
7fbd0e99b27064b14793f028022974e5?d=identicon&s=25 Zhao Yi (youhaodeyi)
on 2009-01-22 08:14
Manmay wrote:
> hi Zhao,
>
> u can use send_file to relate the file in u'r file system but not in
> public dir of u'r rails proj like,
>
> send_file(RAILS_ROOT+"/images_uploaded/"+params[:filename] ,
> :disposition => 'inline')
>

I have tried but got undefined method `send_file' for
#<ActionView::Base:0x41222cc0> error, this is my code in *.html.erb:

...
<td> <%= send_file ('/tmp/log.txt', :disposition => 'inline')
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2009-01-22 09:45
(Received via mailing list)
try to put send_file in an action of your controller.
http://www.railsbrain.com/api/rails-2.2.2/doc/inde...
7fbd0e99b27064b14793f028022974e5?d=identicon&s=25 Zhao Yi (youhaodeyi)
on 2009-01-22 09:59
MaD wrote:
> try to put send_file in an action of your controller.
> http://www.railsbrain.com/api/rails-2.2.2/doc/inde...

I use link_to to an action and in this action I use send_file method. In
this action, how can I get the value of the link_to tag?
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2009-01-22 10:18
(Received via mailing list)
what kind of value do you need?
you can set :params => {:key => :value} and read them in your
controller.
This topic is locked and can not be replied to.