Hello, I have problem with extending spree controller. When I override
controller I cannot get access to Order class. I get following error (I use
spree 1.2.4):

NameError (uninitialized constant Spree::Admin::OrdersController::Order):
spree_russian_post/app/controllers/admin/orders_controller_decorator.rb:9:
in `sample_method'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `
send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in
`process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block inprocess_action
'
activesupport (3.2.8) lib/active_support/callbacks.rb:502:in
`_run__487485795__process_action__526441487__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in
`__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `
_run_process_action_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in
`run_callbacks'

Its my controller: (spree_russian_post/app/controllers/admin/
orders_controller_decorator.rb)


require 'spree_core'

Spree::Admin::OrdersController.class_eval do

def sample_method
@order = Order.find_by_param(params[:id])
....
end

end

What I should do to get access to Order class?

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

  • Michael Sevestre at Mar 13, 2013 at 7:15 pm
    You need to use Spree::Order.find...
    On Mar 13, 2013 3:13 PM, "Mike" wrote:

    Hello, I have problem with extending spree controller. When I override
    controller I cannot get access to Order class. I get following error (I use
    spree 1.2.4):

    NameError (uninitialized constant Spree::Admin::OrdersController::Order):
    spree_russian_post/app/controllers/admin/orders_controller_decorator.rb:
    9:in `sample_method'
    actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `
    send_action'
    actionpack (3.2.8) lib/abstract_controller/base.rb:167:in
    `process_action'
    actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in
    `process_action'
    actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block inprocess_action
    '
    activesupport (3.2.8) lib/active_support/callbacks.rb:502:in
    `_run__487485795__process_action__526441487__callbacks'
    activesupport (3.2.8) lib/active_support/callbacks.rb:405:in
    `__run_callback'
    activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `
    _run_process_action_callbacks'
    activesupport (3.2.8) lib/active_support/callbacks.rb:81:in
    `run_callbacks'

    Its my controller: (spree_russian_post/app/controllers/admin/
    orders_controller_decorator.rb)


    require 'spree_core'

    Spree::Admin::OrdersController.class_eval do

    def sample_method
    @order = Order.find_by_param(params[:id])
    ....
    end

    end

    What I should do to get access to Order class?

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

    --
    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 at Mar 13, 2013 at 8:18 pm
    Michael's right, Spree::Order is the way to do it because the model is
    namespaced. Inside the class_eval, you're not inside the Spree namespace
    and so references to the model need to be pointed to the right namespace.

    On Wed, Mar 13, 2013 at 12:15 PM, Michael Sevestre wrote:

    You need to use Spree::Order.find...
    On Mar 13, 2013 3:13 PM, "Mike" wrote:

    Hello, I have problem with extending spree controller. When I override
    controller I cannot get access to Order class. I get following error (I use
    spree 1.2.4):

    NameError (uninitialized constant Spree::Admin::OrdersController::Order):
    spree_russian_post/app/controllers/admin/orders_controller_decorator.rb
    :9:in `sample_method'
    actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `
    send_action'
    actionpack (3.2.8) lib/abstract_controller/base.rb:167:in
    `process_action'
    actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in
    `process_action'
    actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block inprocess_action
    '
    activesupport (3.2.8) lib/active_support/callbacks.rb:502:in
    `_run__487485795__process_action__526441487__callbacks'
    activesupport (3.2.8) lib/active_support/callbacks.rb:405:in
    `__run_callback'
    activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `
    _run_process_action_callbacks'
    activesupport (3.2.8) lib/active_support/callbacks.rb:81:in
    `run_callbacks'

    Its my controller: (spree_russian_post/app/controllers/admin/
    orders_controller_decorator.rb)


    require 'spree_core'

    Spree::Admin::OrdersController.class_eval do

    def sample_method
    @order = Order.find_by_param(params[:id])
    ....
    end

    end

    What I should do to get access to Order class?

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

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedMar 13, '13 at 7:13p
activeMar 13, '13 at 8:18p
posts3
users3
websitespreecommerce.com
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase