Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails 3 show 404

how to render 404 instead NoMethodError in People#show error

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
like image 841
rails_noob Avatar asked Mar 22 '11 01:03

rails_noob


1 Answers

NoMethodError will render a 500 in production mode, however if you want to also render a 404 status in the headers in development mode, you can do the following:

 redirect_to :status => 404

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

like image 81
Mike Lewis Avatar answered Oct 30 '22 03:10

Mike Lewis