Rails 3 show 404

how to display 404 instead of NoMethodError error in People # show

the code

def show
  @person = Person.find(params[:id])
   respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @person }
  end
end
+5
source share
1 answer

NoMethodError will display 500 in run mode, however, if you want to also display 404 status in headers in design mode, you can do the following:

 redirect_to :status => 404

To display the standard 404 page, you can check the top answer here.

+10
source

All Articles