1
votes
NoMethodError in OrdersController#populate

undefined method `completed?' for nil:NilClass

Gets the above error when i click checkout...any idea.

Full trace

activesupport (3.1.1) lib/active_support/whiny_nil.rb:48:in method_missing' spree_core (0.70.3) app/models/line_item.rb:73:in update_inventory' activesupport (3.1.1) lib/active_support/callbacks.rb:413:in _run_save_callbacks' activesupport (3.1.1) lib/active_support/callbacks.rb:81:insend' activesupport (3.1.1) lib/active_support/callbacks.rb:81:in run_callbacks' activerecord (3.1.1) lib/active_record/callbacks.rb:264:increate_or_update' activerecord (3.1.1) lib/active_record/persistence.rb:37:in save' activerecord (3.1.1) lib/active_record/validations.rb:50:insave' activerecord (3.1.1) lib/active_record/attribute_methods/dirty.rb:22:in save' activerecord (3.1.1) lib/active_record/transactions.rb:241:insave' activerecord (3.1.1) lib/active_record/transactions.rb:295:in with_transaction_returning_status' activerecord (3.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' activerecord (3.1.1) lib/active_record/transactions.rb:208:in transaction' activerecord (3.1.1) lib/active_record/transactions.rb:293:in with_transaction_returning_status' activerecord (3.1.1) lib/active_record/transactions.rb:241:in save' activerecord (3.1.1) lib/active_record/transactions.rb:252:in rollback_active_record_state!' activerecord (3.1.1) lib/active_record/transactions.rb:240:in save' activerecord (3.1.1) lib/active_record/associations/has_many_association.rb:16:in insert_record' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:128:in concat' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:337:in add_to_target' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:127:in concat' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:125:ineach' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:125:in concat' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:147:in transaction' activerecord (3.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' activerecord (3.1.1) lib/active_record/transactions.rb:208:intransaction' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:146:in transaction' activerecord (3.1.1) lib/active_record/associations/collection_association.rb:124:in concat' activerecord (3.1.1) lib/active_record/associations/collection_proxy.rb:118:in <<' spree_core (0.70.3) app/models/order.rb:216:inadd_variant' spree_core (0.70.3) app/controllers/orders_controller.rb:49:in populate' spree_core (0.70.3) app/controllers/orders_controller.rb:47:ineach' spree_core (0.70.3) app/controllers/orders_controller.rb:47:in populate' actionpack (3.1.1) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (3.1.1) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (3.1.1) lib/abstract_controller/base.rb:167:in process_action' actionpack (3.1.1) lib/action_controller/metal/rendering.rb:10:in process_action' actionpack (3.1.1) lib/abstract_controller/callbacks.rb:18:in process_action' activesupport (3.1.1) lib/active_support/callbacks.rb:452:in _run__1106774758__process_action__1039901831__callbacks' activesupport (3.1.1) lib/active_support/callbacks.rb:386:insend' activesupport (3.1.1) lib/active_support/callbacks.rb:386:in _run_process_action_callbacks' activesupport (3.1.1) lib/active_support/callbacks.rb:81:insend' activesupport (3.1.1) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.1.1) lib/abstract_controller/callbacks.rb:17:inprocess_action' actionpack (3.1.1) lib/action_controller/metal/rescue.rb:17:in process_action' actionpack (3.1.1) lib/action_controller/metal/instrumentation.rb:30:inprocess_action' activesupport (3.1.1) lib/active_support/notifications.rb:53:in instrument' activesupport (3.1.1) lib/active_support/notifications/instrumenter.rb:21:ininstrument' activesupport (3.1.1) lib/active_support/notifications.rb:53:in instrument' actionpack (3.1.1) lib/action_controller/metal/instrumentation.rb:29:inprocess_action' actionpack (3.1.1) lib/action_controller/metal/params_wrapper.rb:201:in process_action' activerecord (3.1.1) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (3.1.1) lib/abstract_controller/base.rb:121:in process' actionpack (3.1.1) lib/abstract_controller/rendering.rb:45:inprocess' actionpack (3.1.1) lib/action_controller/metal.rb:193:in dispatch' actionpack (3.1.1) lib/action_controller/metal/rack_delegation.rb:14:in dispatch' actionpack (3.1.1) lib/action_controller/metal.rb:236:in action' actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:65:incall' actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:65:in dispatch' actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:29:in call' rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in call' rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:inrecognize' rack-mount (0.8.3) lib/rack/mount/code_generation.rb:75:in optimized_each' rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:inrecognize' rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in call' actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:532:incall' spree_core (0.70.3) lib/redirect_legacy_product_url.rb:10:in call' spree_core (0.70.3) lib/middleware/seo_assist.rb:23:incall' warden (1.0.6) lib/warden/manager.rb:35:in call' warden (1.0.6) lib/warden/manager.rb:34:incatch' warden (1.0.6) lib/warden/manager.rb:34:in call' actionpack (3.1.1) lib/action_dispatch/middleware/best_standards_support.rb:17:incall' rack (1.3.5) lib/rack/etag.rb:23:in call' rack (1.3.5) lib/rack/conditionalget.rb:35:incall' actionpack (3.1.1) lib/action_dispatch/middleware/head.rb:14:in call' actionpack (3.1.1) lib/action_dispatch/middleware/params_parser.rb:21:incall' actionpack (3.1.1) lib/action_dispatch/middleware/flash.rb:243:in call' rack (1.3.5) lib/rack/session/abstract/id.rb:195:incontext' rack (1.3.5) lib/rack/session/abstract/id.rb:190:in call' actionpack (3.1.1) lib/action_dispatch/middleware/cookies.rb:331:incall' activerecord (3.1.1) lib/active_record/query_cache.rb:62:in call' activerecord (3.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in call' actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in call' activesupport (3.1.1) lib/active_support/callbacks.rb:392:in_run_call_callbacks' activesupport (3.1.1) lib/active_support/callbacks.rb:81:in send' activesupport (3.1.1) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:28:in call' actionpack (3.1.1) lib/action_dispatch/middleware/reloader.rb:68:incall' rack (1.3.5) lib/rack/sendfile.rb:101:in call' actionpack (3.1.1) lib/action_dispatch/middleware/remote_ip.rb:48:incall' actionpack (3.1.1) lib/action_dispatch/middleware/show_exceptions.rb:47:in call' railties (3.1.1) lib/rails/rack/logger.rb:13:incall' rack (1.3.5) lib/rack/methodoverride.rb:24:in call' rack (1.3.5) lib/rack/runtime.rb:17:incall' activesupport (3.1.1) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.3.5) lib/rack/lock.rb:15:incall' actionpack (3.1.1) lib/action_dispatch/middleware/static.rb:53:in call' railties (3.1.1) lib/rails/engine.rb:456:incall' railties (3.1.1) lib/rails/rack/content_length.rb:16:in call' railties (3.1.1) lib/rails/rack/log_tailer.rb:14:incall' rack (1.3.5) lib/rack/handler/webrick.rb:59:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:inservice' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:instart_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in start' /usr/lib/ruby/1.8/webrick/server.rb:162:instart_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:ineach' /usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:instart' /usr/lib/ruby/1.8/webrick/server.rb:82:in start' rack (1.3.5) lib/rack/handler/webrick.rb:13:inrun' rack (1.3.5) lib/rack/server.rb:265:in start' railties (3.1.1) lib/rails/commands/server.rb:70:instart' railties (3.1.1) lib/rails/commands.rb:54 railties (3.1.1) lib/rails/commands.rb:49:in tap' railties (3.1.1) lib/rails/commands.rb:49 script/rails:6:in require' script/rails:6

1
Edit your question and paste in the populate method in your orders_controller. Looks like you have an instance variable thats emptyAndreas Lyngstad
This happens when the line item doesn't link to an order. Could you please provide steps to reproduce that?Ryan Bigg
Actually, It works all well on local machine...rails 3.1.1, ruby 1.8.7 with same gemfile, i'm trying to run it on hostgator VPS, it gives undefined method `completed?' for nil:NilClass ... not able to trace it at all...Kunal Supe
I had to override order.rb file where the error disappears if i comment "self.line_items << current_item " ... but it doesn;t add any product to the cart...Kunal Supe
Now, the issue is somewhere in orders_controller.rb, If i comment @order.add_variant, it redirects to cart_path without added any product to cart params[:variants].each do |variant_id, quantity| quantity = quantity.to_i # @order.add_variant(Variant.find(variant_id), quantity) if quantity > 0 end if params[:variants]Kunal Supe

1 Answers

0
votes

gem 'mysql2' in Gemfile and bundle install worked...