master
 1class ProductsController < ApplicationController
 2  def initialize(product_api = Spank::IOC.resolve(:product_api))
 3    @product_api = product_api
 4    super()
 5  end
 6
 7  def index
 8    @products = @product_api.search(params[:q])
 9    if @products.count == 1
10      redirect_to product_path(@products.first.asin)
11    end
12  end
13
14  def show
15    @product = @product_api.find(params[:id])
16  end
17end