Creating a new model/controller in Spree

1,886 views
Skip to first unread message

Jhudiel Bayotlang

unread,
Jan 28, 2014, 5:07:15 AM1/28/14
to spree...@googlegroups.com
Hi Guys,

I'm new in using spree and I just want to ask is there a way to add new controllers/model to Spree / Spree API

I appreciate any help or suggestion.

Thanks.

Peter Berkenbosch

unread,
Jan 28, 2014, 5:33:18 AM1/28/14
to spree...@googlegroups.com
Hi Jdudiel,

Welcome! 

Please take your time to read through the guides http://guides.spreecommerce.com/developer/

Feel free to ask any question you might have after reading those.

--
Peter Berkenbosch
Developer
Spree Commerce Inc

Spree Commerce

@spreecommerce GitHub Open Source Facebook Google+

Join us in New York City for SpreeConf 2014 February
 26th and 27th.   Learn more
use SpreeConf_PB  for 33% discount!

SpreeConf NY 2014

--
Don't miss SpreeConf on Feb 26-27
http://spreeconf.com

Jhudiel Bayotlang

unread,
Jan 28, 2014, 5:44:02 AM1/28/14
to spree...@googlegroups.com
Hi Peter.

Thanks for your time. I was going through the documentations earlier.. Unfortunately I can find what I'm looking for or I just over read it.. I was wondering if you could help me. I want to add a new controller/model to spree and make as it was part of the api. Is that possible?

Please correct me if I said something wrong.

Thanks.

Peter Berkenbosch

unread,
Jan 28, 2014, 5:54:54 AM1/28/14
to spree...@googlegroups.com
Yes, that’s possible. You just need write the ruby code for that in your application or extension. 

If you just need some additional attributes on the api that’s already there, take a look here: http://guides.spreecommerce.com/integration/custom_attributes.html

--
Peter Berkenbosch
Developer
Spree Commerce Inc

Spree Commerce

@spreecommerce GitHub Open Source Facebook Google+

Join us in New York City for SpreeConf 2014 February
 26th and 27th.   Learn more
use SpreeConf_PB  for 33% discount!

SpreeConf NY 2014


Jhudiel Bayotlang

unread,
Jan 28, 2014, 6:07:24 AM1/28/14
to spree...@googlegroups.com
Oh. Do I need to extend the controllers to a specific spree class?

Gagan Babber

unread,
Aug 25, 2014, 3:43:02 AM8/25/14
to spree...@googlegroups.com
Hey I want to add an admin controller to spree but i could not find any documentation on how to do it . Can u tell me whats the best way to do it. Kinda new to spree and im using latets version of spree

Peter Berkenbosch

unread,
Aug 25, 2014, 4:26:44 AM8/25/14
to spree...@googlegroups.com
You can just generate a controller and decorate the route file for the backend gem. 


Peter.
--

Peter Berkenbosch
Spree Commerce, Inc.

Bryan Stone

unread,
Jan 13, 2015, 11:30:57 AM1/13/15
to spree...@googlegroups.com
This isn't completely helpful, as the tutorial doesn't cover creating a new controller, only extending an existing one.  

Is there a good article for how to extend Spree::Admin::ResourceController?  I have a similar need.

Thank you!

Jeff Dutil

unread,
Jan 13, 2015, 3:09:26 PM1/13/15
to spree...@googlegroups.com
I would recommend reading articles on extending rails controllers in general.

If you want to add an admin controller that inherits from ResourceController it's really pretty much this simple to do:

You just override whichever ResourceController methods you want to within the controller if needed.

Bryan Stone

unread,
Jan 13, 2015, 4:12:26 PM1/13/15
to spree...@googlegroups.com
Thank you - I did have success building a new controller using that template.  If anyone else needs to see a real-world example of an extension adding a custom controller - you can view the extension I just released: https://github.com/aegixx/spree_alternate_prices.  In particular, the price_categories_controller.  The controller is slim, so you'll want to see the views for how I access the resources using @collection & @object.
--
--Bryan

Bryan Stone

unread,
Jan 30, 2015, 2:30:44 PM1/30/15
to spree...@googlegroups.com
Jeff - by the way, my extension spree_alternate_prices may be a good start on the Group pricing/discounts on the Spree Roadmap built on top of the spree_multi_currency.
Reply all
Reply to author
Forward
0 new messages