You can return a file handle and it will be streamed or you can
return a proc and take the response as an arg and write to it, like
this:
# you are better of using send_file here...
def foo
File.open('whatever.txt')
end
def bar
Proc.new{|response|
response.write "hello!"
}
end
Cheers-
-Ezra
On Oct 7, 2008, at 4:21 PM, Joe Van Dyk wrote:
>
> Doh, thanks.
>
> I do need to use p.call though?
>
> What I was trying to do is stream to the client the results of "ping
> somesite." Thought I'd just have to return IO::popen("ping
> somesite.com"), but that didn't seem to work.
>
> On Oct 7, 10:28 am, "Matthijs Langenberg" <[EMAIL PROTECTED]>
> wrote:
>> Hah! You can just return the proc or IO stream! You don't need to
>> call
>> 'render' at all.
>>
>> On Tue, Oct 7, 2008 at 7:03 PM, Julian Leviston
>> <[EMAIL PROTECTED]> wrote:
>>
>>> Yes.
>>
>>> You need to say render p.call if you want the result to be the
>>> result
>>> of the proc's execution.
>>
>>> Julian.
>>
>>> On 08/10/2008, at 3:47 AM, Joe Van Dyk wrote:
>>
>>>> class Test < Application
>>>> def file
>>>> render File.open("/etc/passwd")
>>>> end
>>
>>>> def proc
>>>> p = Proc.new { "hello" }
>>>> render p
>>>> end
>>>> end
>>
>>>> Both those actions don't seem to render anything to the client.
>>
>>>> Am I understanding something incorrectly?
>>
>>>> Joe
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---