app/controllers/products_controller.rb
def create
    authorize! :create, Product
    @product = Product.new(params[:product])
    if @product.save
      unless params[:product_groups].blank? || params[:product_groups][:group_id].blank?
        new_product_group = @product.product_groups.create(params[:product_groups])
      end
      flash[:notice] = t(:product) + t(:created)
      redirect_to edit_product_path(@product.id)
      return
    end
    flash[:error] = t(:product) + t(:needs_a_name)
    redirect_to products_path
  end
# Creates a new product using info entered on the "new" page
Creates a new product using info entered on the "new" page
Creates a new product using info entered on the " new " page
def create
    authorize! :create, Product
    @product = Product.new(params[:product])
    if @product.save
      unless params[:product_groups].blank? || params[:product_groups][:group_id].blank?
        new_product_group = @product.product_groups.create(params[:product_groups])
      end
      flash[:notice] = t(:product) + t(:created)
      redirect_to edit_product_path(@product.id)
      return
    end
    flash[:error] = t(:product) + t(:needs_a_name)
    redirect_to products_path
  end
def create authorize! :create , Product @product = Product . new ( params [ :product ] ) if @product . save unless params [ :product_groups ] . blank? || params [ :product_groups ] [ :group_id ] . blank? new_product_group = @product . product_groups . create ( params [ :product_groups ] ) end flash [ :notice ] = t ( :product ) + t ( :created ) redirect_to edit_product_path ( @product . id ) return end flash [ :error ] = t ( :product ) + t ( :needs_a_name ) redirect_to products_path end
Creates a new product using info entered on the "new" page
Creates a new product using info entered on the " new " page