Hi all, I''m trying to follow the Rails book, and I''m the testing chapter. I was trying to run the code in the page 149 and a DoubleRenderError shows up at the ''get'' line in the following code: def test_index get :index assert_response :success end I''ve read about DoubleRenderError, but they talk about redirect_to, but not about get method. How can I solve this? TIA, Vamsee.
That''s exactly the problem,Vamsee. Since there''s no cookie, you get redirected, so the GET request fails. Kenneth On 8/25/05, Vamsee Kanakala <vamlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > I''m trying to follow the Rails book, and I''m the testing chapter. > I was trying to run the code in the page 149 and a DoubleRenderError > shows up at the ''get'' line in the following code: > > def test_index > get :index > assert_response :success > end > > I''ve read about DoubleRenderError, but they talk about > redirect_to, but not about get method. How can I solve this? > > TIA, > Vamsee. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- => the blog from beyond <=> www.eyeheartzombies.com <=
On 8/25/05, Vamsee Kanakala <vamlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > I''m trying to follow the Rails book, and I''m the testing chapter. > I was trying to run the code in the page 149 and a DoubleRenderError > shows up at the ''get'' line in the following code: > > def test_index > get :index > assert_response :success > end > > I''ve read about DoubleRenderError, but they talk about > redirect_to, but not about get method. How can I solve this?get is a testing method to simulate a get request on an action (index in your case). Check your actual controller for the cause of the DoubleRender error. It''s from calling render or redirect_to multiple times in an action. Be sure to return from an action after calling a render/redirect, or check if one has been performed: redirect_to(:action => ''login'') unless loggedin? render :action => ''show'' # bad, still executed if not loggedin? redirect_to(:action => ''login'') and return unless loggedin? # good render(:action => ''show'') unless performed? Checking performed? may be unnecessary if you properly return from redirect actions. -- rick http://techno-weenie.net