Tuesday 15 June 2010

Render partial Error in ruby on rails -


I have a method that requests to throw 404 if xml, json or html is requested Is

  def render_error (code, status_type = zero) @error = ErrorMessage.new (code, status_type) response_to do | Format | Format.any (: html ,: json) {rendere @ error.partial, position: @ error.status} format.any {Assign to HTML: ErrorMessage.new (404) .partial} End End  

This partial method is

  def partial 'message / show' and  

if I use format.any { Head 404, "content_type" = & gt; Instead of 'text / plain'} instead of format.any {html rendering: ErrorMessage.new (404) .partial} This is an error to me.

  missing template errors / index {: locale = & gt; [: En],: format = & gt; [: Xml] ,: Handlers = & gt; [: Erb,: builder,: raw, ruby, haml]}  

when I request for test.xml , but I'm of a stylistic HTML error Want to use What am I doing wrong here?

Got it .. This work is done by format.any {rendere file: @ error.partial, Content_type: 'text / html', format: [: html], status: @ error.status}


No comments:

Post a Comment