Class: Content::ProductsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Content::ProductsController
- Includes:
- Foreman::Controller::AutoCompleteSearch
- Defined in:
- app/controllers/content/products_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #sync ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/content/products_controller.rb', line 16 def create @product = Product.new(params[:content_product]) if @product.save process_success else process_error end end |
#destroy ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/controllers/content/products_controller.rb', line 43 def destroy if @product.destroy process_success else process_error end end |
#edit ⇒ Object
25 26 |
# File 'app/controllers/content/products_controller.rb', line 25 def edit end |
#index ⇒ Object
6 7 8 9 10 |
# File 'app/controllers/content/products_controller.rb', line 6 def index @products = Product.search_for(params[:search], :order => params[:order]). paginate(:page => params[:page]) @counter = Repository::Product.group(:originator_id).where(:originator_id => @products.map(&:id)).count end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/content/products_controller.rb', line 12 def new @product = Product.new end |
#sync ⇒ Object
36 37 38 39 40 41 |
# File 'app/controllers/content/products_controller.rb', line 36 def sync @product.sync process_success(:success_msg => _("Successfully started sync for %s") % @product.name) rescue => e process_error(:error_msg => _("Failed to start sync for %s") % @product.name) end |
#update ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/content/products_controller.rb', line 28 def update if @product.update_attributes(params[:content_product]) process_success else process_error end end |