On Wed, Jan 21, 2009 at 10:09 PM, Dowker <[email protected]> wrote:

>
> The following exception handlers work fine. It displays a simple page
> with the text "Page Not Found.". But I would like to render the
> message within the application layout.
>
> class ApplicationController < ActionController::Base
>  rescue_from ActionController::RoutingError, :with => :page_not_found
>  rescue_from ActionController::UnknownAction, :with
> => :page_not_found
>
>  protected
>    def page_not_found
>      render :text => 'Page Not Found.', :status => :not_found
>    end
> end
>
> Therefore when I add the layout option to the render method, as such:
>
> class ApplicationController < ActionController::Base
>  rescue_from ActionController::RoutingError, :with => :page_not_found
>  rescue_from ActionController::UnknownAction, :with
> => :page_not_found
>
>  protected
>    def page_not_found
>      render :text => 'Page Not Found.', :layout => true,  :status
> => :not_found
>    end
> end
>
> The response generates a "500 Internal Server Error" error. Can
> anybody shed some light on why this is happening?
>
> Thanks.
>
>
> >
>
You will need to specify which layout to use:
render :text -> 'Page Not Found', :layout => 'application', :status =>
:not_found

-- 
Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to