Double Render Error

Hi,

I keep double render error after updating rails. Heres my code, any
suggestions?

def show
if_user_formulated_request_properly do
@input_messages = InputMessage.search_by(params[:query].strip)
unless params[:query].blank?
end
respond_to do |format|
format.html #default rendering
end
end
end

def if_user_formulated_request_properly
unless request.post?
flash[:error] = “This page can only be accessed through the
search page. (POST request only)”
redirect_to(:action => “index”) and return

end
if params[:query].blank?
  flash[:error] = "Search criteria can not be blank"

redirect_to(:action => “index”) and return

end
if !(params[:query] =~ /-/)
  flash[:error] = "( Format of search criteria is wrong.<br />

Should be [IXLSpecClass value][year]-[Message ID] for example GP07-8)"
redirect_to(:action => “index”) and return

end

if !(QueryParser.expression.match(params[:query]))
  flash[:error] = %( Format of search criteria is wrong.<br /

Should be [IXLSpecClass value][year]-[Message ID] for example GP07-8)
redirect_to(:action => “index”) and return
end
yield

Who wrote that code?

add
respond_to :html

to your controller and change
respond_to do |format|
format.htm …
end

to
respond_with(@input_messages)


tom

ps: or add ‘return’ to your condition if condition has been met (eg in
show method)

On Aug 26, 2011, at 17:59 , jak1192 wrote:

   respond_to do |format|

redirect_to(:action => “index”) and return
redirect_to(:action => “index”) and return

You received this message because you are subscribed to the Google G. “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.

Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz