Skip to content

Instantly share code, notes, and snippets.

@HeroicEric
Created November 10, 2011 16:49
Show Gist options
  • Save HeroicEric/1355366 to your computer and use it in GitHub Desktop.
Save HeroicEric/1355366 to your computer and use it in GitHub Desktop.
ProductsController.class_eval do
def show
product_source = Product.find_by_permalink!(params[:id])
@product = ProductDecorator.new(product_source)
return unless @product
if params[:option_values]
option_values_ids = [
params[:option_values][:cpu].to_i,
params[:option_values][:screen].to_i
]
end
@variants = @product.find_variants(option_values_ids)
@product_properties = ProductProperty.includes(:property).where(:product_id => @product.id)
@selected_variant = @variants.detect { |v| v.available? }
referer = request.env['HTTP_REFERER']
if referer && referer.match(HTTP_REFERER_REGEXP)
@taxon = Taxon.find_by_permalink($1)
end
respond_with(@product)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment