On our app, we had the ability to access the current order by including
Spree::Core::CurrentOrder in our application_controller.rb file. Since
upgrading from Spree 1.2.2 to 1.3.1, we seem to have lost that class and
now a new error has cropped up. With the upgrade to 1.3.1, how do we get
access to the current order outside of the Spree engine?

Here's our Gem file related to Spree:

gem "spree", "1.3.1"
gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch =>
'1-3-stable'
gem 'spree_gateway', :git => 'git://github.com/spree/spree_gateway.git',
:branch => "1-1-stable"

in application_controller.rb, i'm not sure which of these classes to
include anymore:

include Spree::Core::CurrentOrder
or
include Spree::Core::ControllerHelpers::Order

No matter what I do, I get this error when hitting routes outside of the
Spree engine:

undefined local variable or method `try_spree_current_user'


Which seems to be coming from this spree_core method in
/lib/spree/core/controller_helpers/order.rb:

The current incomplete order from the session for use in cart and
during checkout
def current_order(create_order_if_necessary = false)
return @current_order if @current_order
if session[:order_id]
current_order =
Spree::Order.find_by_id_and_currency(session[:order_id], current_currency,
:include => :adjustments)
@current_order = current_order unless
current_order.try(:completed?)
end
if create_order_if_necessary and (@current_order.nil? or
@current_order.completed?)
@current_order = Spree::Order.new(:currency =>
current_currency)
before_save_new_order
@current_order.save!
after_save_new_order
end
if @current_order
@current_order.last_ip_address = ip_address
session[:order_id] = @current_order.id
return @current_order
end
end
--

Search Discussions

  • Ryan Bigg at Jan 30, 2013 at 3:30 am
    You would need to include all the Spree::Core::ControllerHelpers::Auth (for
    try_spree_current_user) and Spree::Core::ControllerHelpers::Order (for
    current_order).

    On Sat, Jan 26, 2013 at 10:41 AM, Randy Burgess wrote:

    On our app, we had the ability to access the current order by including
    Spree::Core::CurrentOrder in our application_controller.rb file. Since
    upgrading from Spree 1.2.2 to 1.3.1, we seem to have lost that class and
    now a new error has cropped up. With the upgrade to 1.3.1, how do we get
    access to the current order outside of the Spree engine?

    Here's our Gem file related to Spree:

    gem "spree", "1.3.1"
    gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch =>
    '1-3-stable'
    gem 'spree_gateway', :git => 'git://github.com/spree/spree_gateway.git',
    :branch => "1-1-stable"

    in application_controller.rb, i'm not sure which of these classes to
    include anymore:

    include Spree::Core::CurrentOrder
    or
    include Spree::Core::ControllerHelpers::Order

    No matter what I do, I get this error when hitting routes outside of the
    Spree engine:

    undefined local variable or method `try_spree_current_user'


    Which seems to be coming from this spree_core method in
    /lib/spree/core/controller_helpers/order.rb:

    The current incomplete order from the session for use in cart and
    during checkout
    def current_order(create_order_if_necessary = false)
    return @current_order if @current_order
    if session[:order_id]
    current_order =
    Spree::Order.find_by_id_and_currency(session[:order_id], current_currency,
    :include => :adjustments)
    @current_order = current_order unless
    current_order.try(:completed?)
    end
    if create_order_if_necessary and (@current_order.nil? or
    @current_order.completed?)
    @current_order = Spree::Order.new(:currency =>
    current_currency)
    before_save_new_order
    @current_order.save!
    after_save_new_order
    end
    if @current_order
    @current_order.last_ip_address = ip_address
    session[:order_id] = @current_order.id
    return @current_order
    end
    end
    --

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedJan 25, '13 at 11:41p
activeJan 30, '13 at 3:30a
posts2
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Randy Burgess: 1 post Ryan Bigg: 1 post

People

Translate

site design / logo © 2022 Grokbase