Birgit Arkesteijn
2008-Jul-17 12:34 UTC
Newbie: how to use link_to to create ftp url to download a file?
Hi everyone, I''m struggling with link_to. I''m trying to generate a link that will enable my web users to ftp a file. Table ''calls'' contains a field ''filename''. There the requirement to download this file via ftp. For example: calls.filename = ''/project/tmp/file/README.txt'' should convert to <a href="ftp:///project/tmp/file/README.txt">/project/tmp/file/README.txt</a> (or whatever the number of slashes is after ''ftp:'') Thanks, Birgit -- -- Birgit Arkesteijn, birgit-YRFHH29wTjy9FHfhHBbuYA@public.gmane.org, -- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK -- Company no: 1769350 -- Registered Office: -- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK. -- tel.: +44 (0)161 237 0660 -- <URL: http://www.westhawk.co.uk> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Birgit Arkesteijn
2008-Jul-17 12:38 UTC
Re: Newbie: how to use link_to to create ftp url to download a file?
Hi, I realise there is one more issue here. The ''calls'' table also contains the ip address of the machine that hosts the file. So calls.ip_address = 123.456.789.123 This should find its way to the ftp url as well: ftp://123.456.789.123/project/tmp/file/README.txt Thanks, Birgit On 17/07/08 13:34, Birgit Arkesteijn wrote:> Hi everyone, > > I''m struggling with link_to. > I''m trying to generate a link that will enable my web users to ftp a file. > > Table ''calls'' contains a field ''filename''. There the requirement to > download this file via ftp. > > For example: > calls.filename = ''/project/tmp/file/README.txt'' > > should convert to > <a > href="ftp:///project/tmp/file/README.txt">/project/tmp/file/README.txt</a> > (or whatever the number of slashes is after ''ftp:'') > > Thanks, Birgit >-- -- Birgit Arkesteijn, birgit-YRFHH29wTjy9FHfhHBbuYA@public.gmane.org, -- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK -- Company no: 1769350 -- Registered Office: -- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK. -- tel.: +44 (0)161 237 0660 -- <URL: http://www.westhawk.co.uk> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jul-17 12:56 UTC
Re: Newbie: how to use link_to to create ftp url to download a file?
On 17 Jul 2008, at 13:38, Birgit Arkesteijn wrote:> > Hi, > > I realise there is one more issue here. > The ''calls'' table also contains the ip address of the machine that > hosts > the file. >Do the :protocol and :host options help you? Fred> So > calls.ip_address = 123.456.789.123 > > This should find its way to the ftp url as well: > ftp://123.456.789.123/project/tmp/file/README.txt > > Thanks, Birgit > > On 17/07/08 13:34, Birgit Arkesteijn wrote: >> Hi everyone, >> >> I''m struggling with link_to. >> I''m trying to generate a link that will enable my web users to ftp >> a file. >> >> Table ''calls'' contains a field ''filename''. There the requirement to >> download this file via ftp. >> >> For example: >> calls.filename = ''/project/tmp/file/README.txt'' >> >> should convert to >> <a >> href="ftp:///project/tmp/file/README.txt">/project/tmp/file/ >> README.txt</a> >> (or whatever the number of slashes is after ''ftp:'') >> >> Thanks, Birgit >> > > -- > -- Birgit Arkesteijn, birgit-YRFHH29wTjy9FHfhHBbuYA@public.gmane.org, > -- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK > -- Company no: 1769350 > -- Registered Office: > -- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK. > -- tel.: +44 (0)161 237 0660 > -- <URL: http://www.westhawk.co.uk> > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Birgit Arkesteijn
2008-Jul-17 13:54 UTC
Re: Newbie: how to use link_to to create ftp url to download a file?
Hi Fred,
Thanks for your help.
I''ve seen :protocol and :host. I''m more struggling what to do
with
call.filename itself?
If "call.filename" is the value, what is the key that goes with it?
<%= link_to call.filename,
{:protocol => ''ftp'', :host => call.ip_address} %>
Thanks, Birgit
On 17/07/08 13:56, Frederick Cheung wrote:>
> On 17 Jul 2008, at 13:38, Birgit Arkesteijn wrote:
>
>> Hi,
>>
>> I realise there is one more issue here.
>> The ''calls'' table also contains the ip address of the
machine that
>> hosts
>> the file.
>>
> Do the :protocol and :host options help you?
>
> Fred
>
>> So
>> calls.ip_address = 123.456.789.123
>>
>> This should find its way to the ftp url as well:
>> ftp://123.456.789.123/project/tmp/file/README.txt
>>
>> Thanks, Birgit
>>
>> On 17/07/08 13:34, Birgit Arkesteijn wrote:
>>> Hi everyone,
>>>
>>> I''m struggling with link_to.
>>> I''m trying to generate a link that will enable my web
users to ftp
>>> a file.
>>>
>>> Table ''calls'' contains a field
''filename''. There the requirement to
>>> download this file via ftp.
>>>
>>> For example:
>>> calls.filename = ''/project/tmp/file/README.txt''
>>>
>>> should convert to
>>> <a
>>>
href="ftp:///project/tmp/file/README.txt">/project/tmp/file/
>>> README.txt</a>
>>> (or whatever the number of slashes is after
''ftp:'')
>>>
>>> Thanks, Birgit
>>>
>> --
>> -- Birgit Arkesteijn, birgit-YRFHH29wTjy9FHfhHBbuYA@public.gmane.org,
>> -- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
>> -- Company no: 1769350
>> -- Registered Office:
>> -- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
>> -- tel.: +44 (0)161 237 0660
>> -- <URL: http://www.westhawk.co.uk>
>>
>
>
> >
--
-- Birgit Arkesteijn, birgit-YRFHH29wTjy9FHfhHBbuYA@public.gmane.org,
-- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
-- Company no: 1769350
-- Registered Office:
-- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
-- tel.: +44 (0)161 237 0660
-- <URL: http://www.westhawk.co.uk>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Birgit Arkesteijn
2008-Jul-21 11:13 UTC
Re: Newbie: how to use link_to to create ftp url to download a file?
Hi Everyone,
For those who might struggle like myself, this is how I solved my
problem in the end.
I added a helper method to my call model, called to_url():
def to_url(call)
if (call.filename) then
uri2 = URI::FTP.build({:host => call.ip_address,
:path => call.filename})
uri2.to_s
else
''''
end
end
In my index view, I call:
<%= link_to call.filename, to_url(call) %>
Cheers, Birgit
On 17/07/08 14:54, Birgit Arkesteijn wrote:> Hi Fred,
>
> Thanks for your help.
> I''ve seen :protocol and :host. I''m more struggling what
to do with
> call.filename itself?
>
> If "call.filename" is the value, what is the key that goes with
it?
> <%= link_to call.filename,
> {:protocol => ''ftp'', :host => call.ip_address}
%>
>
> Thanks, Birgit
>
> On 17/07/08 13:56, Frederick Cheung wrote:
>> On 17 Jul 2008, at 13:38, Birgit Arkesteijn wrote:
>>
>>> Hi,
>>>
>>> I realise there is one more issue here.
>>> The ''calls'' table also contains the ip address of
the machine that
>>> hosts
>>> the file.
>>>
>> Do the :protocol and :host options help you?
>>
>> Fred
>>
>>> So
>>> calls.ip_address = 123.456.789.123
>>>
>>> This should find its way to the ftp url as well:
>>> ftp://123.456.789.123/project/tmp/file/README.txt
>>>
>>> Thanks, Birgit
>>>
>>> On 17/07/08 13:34, Birgit Arkesteijn wrote:
>>>> Hi everyone,
>>>>
>>>> I''m struggling with link_to.
>>>> I''m trying to generate a link that will enable my web
users to ftp
>>>> a file.
>>>>
>>>> Table ''calls'' contains a field
''filename''. There the requirement to
>>>> download this file via ftp.
>>>>
>>>> For example:
>>>> calls.filename =
''/project/tmp/file/README.txt''
>>>>
>>>> should convert to
>>>> <a
>>>>
href="ftp:///project/tmp/file/README.txt">/project/tmp/file/
>>>> README.txt</a>
>>>> (or whatever the number of slashes is after
''ftp:'')
>>>>
>>>> Thanks, Birgit
--
-- Birgit Arkesteijn, birgit-YRFHH29wTjy9FHfhHBbuYA@public.gmane.org,
-- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
-- Company no: 1769350
-- Registered Office:
-- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
-- tel.: +44 (0)161 237 0660
-- <URL: http://www.westhawk.co.uk>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---