Cannot redirect to nil!

I need some help please…

when I created web application about books market, i create a cart and using test the message error appear like this on rake test:functionals

LineItemsControllerTest test_should_create_line_item ERROR Cannot redirect to nil! and also appear on web side, thats error told that “Cannot redirect to nil!”

Then i was checking the code, and i think that’s nothing need to do, all it’s normal.

somebody may have an experienced on it, please tell me how to resolve this.

thankyou…

Is that all it says? Is there no stack trace? If there is show us the complete error and stack trace (either from the test or from the website itself), and the code around where the error is generated. Presumably there is a redirect call there, look closely at it to see why it might be trying to redirect to nil.

Colin

oh sorry, here i attach the complete errors from test:

LineItemsControllerTest test_should_create_line_item ERROR Cannot redirect to nil! STDERR: Exception ActionController::ActionControllerError' at /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/redirecting.rb:60:in redirect_to’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/flash.rb:25:in redirect_to' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:60:in block in redirect_to’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in block in instrument' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in instrument’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in instrument' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:59:in redirect_to’ app/controllers/line_items_controller.rb:50:in block (2 levels) in create' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/mime_responds.rb:195:in call’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/mime_responds.rb:195:in respond_to' app/controllers/line_items_controller.rb:48:in create’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/implicit_render.rb:4:in send_action' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/abstract_controller/base.rb:167:in process_action’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/rendering.rb:10:in process_action' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/abstract_controller/callbacks.rb:18:in block in process_action’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:416:in _run__909953372__process_action__930268695__callbacks' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:386:in _run_process_action_callbacks’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in run_callbacks' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/abstract_controller/callbacks.rb:17:in process_action’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/rescue.rb:17:in process_action' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:30:in block in process_action’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in block in instrument' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in instrument’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in instrument' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:29:in process_action’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/params_wrapper.rb:201:in process_action' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/railties/controller_runtime.rb:18:in process_action’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/abstract_controller/base.rb:121:in process' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:45:in process’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/metal/testing.rb:17:in process_with_new_base_test' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/test_case.rb:449:in process’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/test_case.rb:49:in process' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.1.3/lib/action_controller/test_case.rb:370:in post’ test/functional/line_items_controller_test.rb:21:in block (2 levels) in <class:LineItemsControllerTest>' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/testing/assertions.rb:55:in assert_difference’ test/functional/line_items_controller_test.rb:20:in block in <class:LineItemsControllerTest>' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/testing/setup_and_teardown.rb:35:in block in run’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:444:in _run_setup_callbacks' /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in run_callbacks’ /home/hirokakaoshi/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.1.3/lib/active_support/testing/setup_and_teardown.rb:34:in `run’

and here from website :

ActionController::ActionControllerError in LineItemsController#create

Cannot redirect to nil!

Rails.root: /home/hirokakaoshi/Project/RoR/depot

Application Trace | Framework Trace | Full Trace

app/controllers/line_items_controller.rb:50:in `block (2 levels) in create'
app/controllers/line_items_controller.rb:48:in `create'

Request

Parameters:

 {"authenticity_token"=>"ffpMM03w5smCVm9JfyphEaWBQA1wDg6nphecslhJ1Y8=",
"product_id"=>"10"}

Show session dump

Show env dump

Response

Headers:

None

that’s all, all i need is to update tables of cart and product together when i clicked at add button… but it can’t.

I want to redirect an id to cart in line item, coz line item is belongs to product and cart. but it say that redirect is nil!.

That says the error is occurring in your code at line 50. Perhaps it would be useful if you posted that area of your code so that we can see it. Probably best to post the whole of the create method. First though, as I suggested in my previous post, look carefully at that code and see if you can see why it might be trying to redirect to nil.

Colin