Reputation: 15129
I am doing a Favorites functionality in my app built on top of Spree. I want to write my very own controller/action to serve adding a product to favorites. What I want have is the following url:
/product/:product_permalink/favorite
...to mark the product as favorite for currently logged in user.
Currently I do the following:
match 'favorites' => 'favorites#index'
match 'products/:id/favorite' => 'favorites#create', as: 'favorites'
match 'products/:id/unfavorite' => 'favorites#destroy', as: 'unfavorite'
Yet the true way of doing this would be hooking into Spree products
resources route, adding proper members. But is it even possible?
Upvotes: 2
Views: 1046
Reputation: 269
You Could do
Spree::Product.class_eval do
#Add your custom logic here
end
Then do the same in your controller and views to plug your functionality directly into the products model and controller.
you can check out the documentation over at http://guides.spreecommerce.com/logic_customization.html
It's very useful :)
Thanks
Ash
Upvotes: 1