Class: ProductsController
- Inherits:
-
InheritedResources::Base
- Object
- InheritedResources::Base
- ProductsController
- Defined in:
- app/controllers/products_controller.rb
Instance Method Summary collapse
Instance Method Details
#by_permalink ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/products_controller.rb', line 27 def by_permalink if @product = Product.find_by_permalink(params['path']) render :template => 'products/show' else render :template => 'public/404.html', :status => '404' end end |
#edit ⇒ Object
5 6 7 8 |
# File 'app/controllers/products_controller.rb', line 5 def edit @product = Product.find_by_permalink(params['id']) || Product.find_by_id(params['id']) edit! end |
#search ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/products_controller.rb', line 15 def search # http://railscasts.com/episodes/120-thinking-sphinx with will_paginate # @products = Product.search(params[:q], :page => 1, :per_page => 5, :order => :name) @products = Product.where('name like ? or tags like ?', "%#{params['q']}%", "%#{params['q']}%").paginate(:per_page => 10, :page => params[:page]) respond_to do |format| format.html { render :template => 'products/search/index' } format.xml { render :xml => @products } end end |