> I''m attempting to deal with some DoubleRenderError exceptions and
am
> looking for advice on how to handle a form submitted by a default
> action.
> 
> I have a controller with:
> 
> def index
>   do_something
>   render do_something
> end
> 
> def do_something
>   # some code which determines if a form was submitted successfully
>   if success
>     redirect_to :action => "report_success"
>   end
> end
> 
> And within the do_something view:
> 
> <%= start_form_tag %>
> 
> The DoubleRenderError exception occurs when a user submits the form.
> Rails does the do_something action''s redirect_to, then attempts to
do
> the index action''s render.  I believe this is because the
> start_form_tag uses the default action (index) instead of the actual
> action that was used to generate the view.  Without explicitly setting
> the action in the view, is there some other way to overcome this
> exception?
Following Jamis Buck''s advice at
http://jamis.jamisbuck.org/articles/2005/07/08/rails-tip-of-the-day,
you should either return after redirects/renders, or check the
performed? value.  Since you have your redirect in another method,
returning won''t necessarily help. It will still call the render below
it.
def index
 do_something
 render(do_something) unless performed?
end
def do_something
 # some code which determines if a form was submitted successfully
 if success
   redirect_to :action => "report_success"
 end
end
-- 
rick
http://techno-weenie.net