On 6/23/05, Payam Fard
<p_fard_2000-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> I have a search page asking for some criteria. The
> search method in my controller does its thing and sets
> the @assignments collection. Then finally I do the
> following redirection to the report page so that I can
> show the results nicely. Before doing the following, I
> print the contents of the collection and it is not
> nil.
>
> redirect_to :action => ''report''
>
> I have an empty method in my controller call report.
> When I go to the report.rhtml for some reason the
> contents of my collection becomes nil and therefore I
> get the error in the subject line when I try to
> iterate through the collection.
>
> Any ideas what the problem could be?
Yep, redirect_to sends an HTTP redirect to the browser, which then
makes a *seperate* request for the new controller. This second
request has a new instance of the controller so your collection is
nil.
What you''re after is either:
* Use render_action instead of redirect_to
* Stick the collection in the flash and retrieve it in the report controller.
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Cheers
Koz