Forum: Ruby on Rails return custom http responses from a controller?

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.
Aaron S. (Guest)
on 2007-06-30 08:03
Is it possible to have a response to the browser triggered prematurely
in a controller? like before rails does all it's internal processing?

also if so can I change the content-type for the response?

thanks
Aaron S. (Guest)
on 2007-06-30 08:04
Aaron S. wrote:
> Is it possible to have a response to the browser triggered prematurely
> in a controller? like before rails does all it's internal processing?
>
> also if so can I change the content-type for the response?
>
> thanks

Also, besides the content-type, how can I supply a custom response body?
snacktime (Guest)
on 2007-06-30 08:24
(Received via mailing list)
On 6/29/07, Aaron S. <removed_email_address@domain.invalid> wrote:
>
> Aaron S. wrote:
> > Is it possible to have a response to the browser triggered prematurely
> > in a controller? like before rails does all it's internal processing?
> >
> > also if so can I change the content-type for the response?
> >
> > thanks
>
> Also, besides the content-type, how can I supply a custom response body?

render is what supplies the response body.  There are just more ways
to render then you are aware of.   render :text => 'test', render
:file =>file, render_xml, etc..

To set headers do this before rendering:

headers["Content-Type"] = 'mycontenttype'

Chris
Aaron S. (Guest)
on 2007-06-30 08:55
perfect. thanks.
This topic is locked and can not be replied to.