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.
1b275ea705cc1671f13105d29684cbec?d=identicon&s=25 Scott F. Walter (Guest)
on 2006-04-03 04: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.
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2006-04-03 04:49
(Received via mailing list)
Greetings Scott

Yep, you're right

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

cheers,
Jodi
41e1579600683eed6c00af9a425268e6?d=identicon&s=25 Edward Frederick (Guest)
on 2006-04-03 05:13
(Received via mailing list)
Is something preventing...

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

...from being apropos?
1b275ea705cc1671f13105d29684cbec?d=identicon&s=25 Scott F. Walter (Guest)
on 2006-04-03 15:13
Edward Frederick 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.