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
def self.similar(current_product) | |
semilars = self.where(:part_id => current_product.part_id, :model_id => current_product.model_id) | |
if semilars.count < 5 | |
semilars |= self.where(:model_id => current_product.model_id) | |
if semilars.count < 5 | |
sem = semilars | self.all | |
else | |
semilars | |
end | |
end |
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
redirect_to product_path(@search.first) if @search.count == 1 | |
#AbstractController::DoubleRenderError in ProductsController#index | |
#Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return". |
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 |
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
context :search do | |
before { get :index, :search => { :full_search => product.name } } | |
context :with_one_product do | |
it do | |
get :show, :id => product.id | |
response.should be_success | |
end | |
end | |
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
class ProductsController < InheritedResources::Base | |
actions :show, :index | |
before_filter LocationGonFilter, :only => [:show] | |
def show | |
show! do | |
@silimiar_products = ProductDecorator.decorate(Product.similar(@product)) } #как это метод после объявления приминять? | |
end | |
end |