1) You could also change it to be @order.next_transition &&
@order.next_transition.run_callbacks, which would do the same thing and be
shorter. Your version is cleaner... although if
@order.next_transition.present? would be an even cleaner version of that,
removing the "double negative" combination of "unless" and "nil"
2) Yes, please file a GitHub PR for this.


On Sun, Mar 24, 2013 at 12:41 PM, Nate Lowrie
wrote:
I am using Spree 1.2. I am getting an error when I go through a specific
checkout procedure:

1. Add items to the cart, any item will do.
2. Check and go through the process to the payment page.
3. Go back to the cart.
4. Add or delete an item.
5. Click Checkout and I get the following error:

NoMethodError (undefined method `run_callbacks' for nil:NilClass):

/home/fineline/rails_apps/spree-fine-line-automation/shared/bundle/ruby/1.8/bundler/gems/spree-6dc5357c7dd1/core/app/controllers/spree/orders_controller.rb:21:in
`update'

/home/fineline/rails_apps/spree-fine-line-automation/shared/bundle/ruby/1.8/bundler/gems/spree-6dc5357c7dd1/core/lib/spree/core/respond_with.rb:14:in
`call'

/home/fineline/rails_apps/spree-fine-line-automation/shared/bundle/ruby/1.8/bundler/gems/spree-6dc5357c7dd1/core/lib/spree/core/respond_with.rb:14:in
`respond_with'

/home/fineline/rails_apps/spree-fine-line-automation/shared/bundle/ruby/1.8/bundler/gems/spree-6dc5357c7dd1/core/app/controllers/spree/orders_controller.rb:18:in
`update'

The code in question is:

def update
@order = current_order
if @order.update_attributes(params[:order])
@order.line_items = @order.line_items.select {|li| li.quantity > 0
}
fire_event('spree.order.contents_changed')
respond_with(@order) do |format|
format.html do
if params.has_key?(:checkout)
@order.next_transition.run_callbacks
redirect_to checkout_state_path(@order.checkout_steps.first)
else
redirect_to cart_path
end
end
end
else
respond_with(@order)
end
end

It is bombing because @order.next_transition is returning Nil. Note that
changing it to @order.next_transition.run_callbacks unless
@order.next_transition.nil? solved the issue and I haven't had any adverse
issues with it.

1) Is this fix a good fix to have? I don't know why the state machine is
returning nil so I can't be sure that it's a best practice. The tests
passed btw.
2) Should I file a github issue for this?

Regards,

Nate

--
You received this message because you are subscribed to the Google Groups
"Spree" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to spree-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

Ryan Bigg
Community Manager
Spree Commerce, Inc.

Register now for SpreeConf
May 20-21 in Washington, D.C.
http://spreeconf.com

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedMar 26, '13 at 10:19p
activeMar 26, '13 at 10:19p
posts1
users1
websitespreecommerce.com
irc#RubyOnRails

1 user in discussion

Ryan Bigg: 1 post

People

Translate

site design / logo © 2022 Grokbase