Permalink
Browse files

Add Spree namespace to code samples

  • Loading branch information...
1 parent b2fb9a8 commit 09d04de7cd525de9bb6ca261268b819610054aa8 @lucapette lucapette committed Jan 23, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 source/logic_customization.textile
@@ -27,7 +27,7 @@ NOTE: To activate your decorators you need to include the follow code in your *l
**Adding a custom method to the Product model:** app/models/product_decorator.rb
<ruby>
- Product.class_eval do
+ Spree::Product.class_eval do
def some_method
...
end
@@ -38,7 +38,7 @@ NOTE: To activate your decorators you need to include the follow code in your *l
**Adding a custom action to the ProductsController:** app/controllers/products_controller_decorator.rb
<ruby>
- ProductsController.class_eval do
+ Spree::ProductsController.class_eval do
def some_action
...
end
@@ -52,7 +52,7 @@ h4. Accessing Product Data
If you extend the Products controller with a new method, you may very well want to access product data in that method. You can do so by using the :load_data before_filter.
<ruby>
- ProductsController.class_eval do
+ Spree::ProductsController.class_eval do
before_filter :load_data, :only => :some_action
def some_action
@@ -86,15 +86,15 @@ h4. Example Usage
If you wanted to render a custom partial for the index action of ProductsController, you could include the following in your *app/controllers/products_controller_decorator.rb* file.
<ruby>
- ProductsController.class_eval do
+ Spree::ProductsController.class_eval do
respond_override :index => { :html => { :success => lambda { render :partial => "shared/some_file" } } }
end
</ruby>
Or if you wanted to redirect on the failure to create in Admin::ProductsController, you would use:
<ruby>
- Admin::ProductsController.class_eval do
+ Spree::Admin::ProductsController.class_eval do
respond_override :create => { :html => { :failure => lambda { redirect_to some_url } } }
end
</ruby>
@@ -109,7 +109,7 @@ h3. Product Images
Spree uses Thoughtbot's "paperclip":https://github.com/thoughtbot/paperclip gem to manage images for products. All the normal paperclip options are available on the Image class. If you want to modify the default spree product and thumbnail image sizes, simply create an image_decorator.rb file in your app model directory, and override the attachment sizes:
<ruby>
- Image.class_eval do
+ Spree::Image.class_eval do
attachment_definitions[:attachment][:styles] = {
:mini => '48x48>', # thumbs under image
:small => '100x100>', # images on category view

0 comments on commit 09d04de

Please sign in to comment.