Forum: Ruby on Rails How do I programmatically send a 404 error

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.
Scott F. Walter (Guest)
on 2006-04-03 06:33
I want to programmatically under certain conditions return a 404 (page
not found) error to the browser.  How can I do this from my controller?

I'm assuming I need to set a header on the reponse obect.  However I
can't figure out what the header name is.

thanks, scott.
Jodi S. (Guest)
on 2006-04-03 06:49
(Received via mailing list)
Greetings Scott

Yep, you're right

           response.headers["Status"] = "404"

cheers,
Jodi
Edward F. (Guest)
on 2006-04-03 07:13
(Received via mailing list)
Is something preventing...

render :nothing => true, :status => 404

...from being apropos?
Scott F. Walter (Guest)
on 2006-04-03 17:13
Edward F. wrote:
> Is something preventing...
>
> render :nothing => true, :status => 404
>
> ...from being apropos?

ahh.  Much, more,elegant!
This topic is locked and can not be replied to.