Problem modifying order model: uninitialized constant Order (NameError) - Spree 0.60.1

192 views
Skip to first unread message

Filipe Moreira

unread,
Sep 15, 2011, 4:44:05 PM9/15/11
to spree...@googlegroups.com
Hi all,

This is my first post on the list but before I ask for help I would to thank you all for the wonderful platform that you have created. 

On a project I'm working on there is a need for a donation/donate functionality. I've followed the customization guide (http://spreecommerce.com/documentation/customization.html) to add new logic to the Order model.

I've added a new file called 'order_decorator.rb'  inside 'app/models' and added:

Order.class_eval do
  def my_method
    # custom code
  end
end

and I'm getting the following error: 

order_decorator.rb:1:in `<top (required)>': uninitialized constant Order (NameError)

Anyone can add some light to my problem?

Thank you,

Filipe Moreira

Brian Quinn

unread,
Sep 16, 2011, 4:35:14 AM9/16/11
to spree...@googlegroups.com
Hi Filipe,
Welcome to spree-user, we need a few more details before we can help with your issue:

1) What version of Spree are you running

2) Where do you get that error?

Thanks,

Brian Quinn

-------------------------------------------
Rails Dog LLC
2 Wisconsin Circle, Suite 700
Chevy Chase, MD 20815
-------------------------------------------

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/PunIfcPJgdgJ.
To post to this group, send email to spree...@googlegroups.com.
To unsubscribe from this group, send email to spree-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Filipe Moreira

unread,
Sep 16, 2011, 4:52:49 AM9/16/11
to spree...@googlegroups.com
Hi Brian,

Thanks for the help. I'm running version 0.60.1 and Rails 3.0.9. The error I get on startup on both the normal and console way (rails s and rails c). 


Brian Quinn

unread,
Sep 16, 2011, 4:58:32 AM9/16/11
to spree...@googlegroups.com
Ok, so can you do a pastie of your spree_site.rb , that error reads like the decorator include block is being executed too early.

You want it inside the activate method in spree_site.rb

Brian Quinn

-------------------------------------------
Rails Dog LLC
2 Wisconsin Circle, Suite 700
Chevy Chase, MD 20815
-------------------------------------------

On Friday 16 September 2011 at 09:52, Filipe Moreira wrote:

Hi Brian,

Thanks for the help. I'm running version 0.60.1 and Rails 3.0.9. The error I get on startup on both the normal and console way (rails s and rails c). 


--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/V3xUAYMBPVoJ.

Filipe Moreira

unread,
Sep 16, 2011, 5:04:42 AM9/16/11
to spree...@googlegroups.com
Hi Brian,

It worked. I moved the 'require' inside the self.activate block and the error disappeared.

Thank you for the quick reply.

Filipe Moreira
Reply all
Reply to author
Forward
0 new messages