Scaffold code fails functional test?


#1

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:

  1. Failure:
    test_edit(StudentControllerTest)
    [test/functional/student_controller_test.rb:68]:
    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