I am doing a lot of API development and tend to interact with my rails app from a command line or network proxy.
How can I make rails use plaintext errors and ba开发者_运维百科cktraces instead of html ones?
Errors are printed in the server log as plaintext. If you don't have easy access to the logs, you could write a custom exception handler which would print the error to the user in plaintext.
You can also change your responds_to
handling:
def create
company = params[:person].delete(:company)
@company = Company.find_or_create_by_name(company[:name])
@person = @company.people.create(params[:person])
respond_to do |format|
format.html { redirect_to(person_list_url) }
format.js
format.xml { render :xml => @person.to_xml(:include => @company) }
end
end
So if you're rendering xml, json, or text, you've got options for output, and Rails shouldn't be generating HTML error messages.
精彩评论