Forum: Ruby on Rails scaffold code fails functional test?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bakki K. (Guest)
on 2006-01-06 23:31
(Received via mailing list)
I have the following scaffold generated code which does not run. It does
not
even hit the breakpoint.

  def create
    breakpoint()
    @student = Student.new(params[:student])
    if @student.save
      flash[:notice] = 'Student was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

 I decided to run functional test on the controller. Here is the result:

  1) Failure:
test_create(StudentControllerTest)
[test/functional/student_controller_test.rb:55]:
Expected response to be a <:redirect>, but was <200>

Also from another action I get the following error:

  2) Failure:
test_edit(StudentControllerTest)
[test/functional/student_controller_test.rb:68]:
<false> is not true.

I don't undertand why this code fails and what the failure means.

Can someone also please explain when to use redirect_to vs. render?
Thanks
for your help.

-bakki kudva
This topic is locked and can not be replied to.