Class: Refinery::Products::Admin::ProductsController
- Inherits:
-
AdminController
- Object
- AdminController
- Refinery::Products::Admin::ProductsController
- Defined in:
- app/controllers/refinery/products/admin/products_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
———————————————————————-.
-
#update ⇒ Object
———————————————————————-.
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/refinery/products/admin/products_controller.rb', line 13 def create # set this object as last object, given the conditions of this class. params[:product].merge!({ :position => ((::Refinery::Products::Product.maximum(:position, :conditions => "")||-1) + 1) }) @product = ::Refinery::Products::Product.new(params[:product]) if @product.valid? && @product.save flash.notice = t( 'refinery.crudify.created', :what => "#{@product.name}") # successful creation if params[:digi_download] == '1' # .. is digi_download needed too? redirect_to refinery.new_products_admin_digidownload_path( :product_id => @product.id ) else #..straightforward create; redirect_to :back end else # unsuccesful create render :action => :new end end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/refinery/products/admin/products_controller.rb', line 41 def update if @product.update_attributes(params[:product]) # successful update flash.notice = t( 'refinery.crudify.updated', :what => "#{@product.name}") if params[:digi_download] == '1' # .. is digi_download needed too? redirect_to refinery.new_products_admin_digidownload_path( :product_id => @product.id ) else #..straightforward update redirect_to :back end else # ... failed update render :action => :edit end end |