Created
December 26, 2012 09:02
-
-
Save roushkaman/4379020 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding : utf-8 -*- | |
class ProductsController < InheritedResources::Base | |
actions :show, :index | |
before_filter LocationGonFilter, :only => [:show] | |
def show | |
show! { @silimiar_products = ProductDecorator.decorate(Product.similar(@product.car_and_part_name)) } | |
end | |
def index | |
index! { redirect_to(product_path(collection.first)) if collection.count == 1 } | |
end | |
private | |
def collection | |
params[:search] ||= {} | |
params[:search][:full_search] ||= '' | |
@search ||= Product.search(params[:search]) | |
@products ||= ProductDecorator.decorate @search.relation.default_order(seller_address).all | |
@hot_products = ProductDecorator.decorate(Product.latest_products) | |
end | |
def resource | |
@product ||= ProductDecorator.decorate(super) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment