app/controllers/portfolios_controller.rb
def update
    unless params[:new_product_group_portfolios].blank?
      params[:new_product_group_portfolios].to_a.each do |new_pg|
        new_pg = new_pg.last
        unless new_pg.blank? || new_pg["product_id"].blank?
          if @portfolio.product_group_portfolios.new(new_pg).save
            flash[:notice] = "Product added."
          end
        end
      end
    end
    @portfolio.update_attributes(params[:portfolio])
    flash[:notice] = "Portfolio updated"
    redirect_to edit_portfolio_path(@portfolio.id)
  end
# Adds new product to the portfolio if one is supplied, removes any which were marked for removal.
# If a new product is added, also adds it to the group's list of products if it is not already in 
# it. 
Adds new product to the portfolio if one is supplied, removes any which were marked for removal.
If a new product is added, also adds it to the group's list of products if it is not already in
it.
Adds new product to the portfolio if one is supplied removes any which were marked for removal . If a new product is added also adds it to the group ' s list of products if it is not already in it .
def update
    unless params[:new_product_group_portfolios].blank?
      params[:new_product_group_portfolios].to_a.each do |new_pg|
        new_pg = new_pg.last
        unless new_pg.blank? || new_pg["product_id"].blank?
          if @portfolio.product_group_portfolios.new(new_pg).save
            flash[:notice] = "Product added."
          end
        end
      end
    end
    @portfolio.update_attributes(params[:portfolio])
    flash[:notice] = "Portfolio updated"
    redirect_to edit_portfolio_path(@portfolio.id)
  end
def update unless params [ :new_product_group_portfolios ] . blank? params [ :new_product_group_portfolios ] . to_a . each do | new_pg | new_pg = new_pg . last unless new_pg . blank? || new_pg [ "product_id" ] . blank? if @portfolio . product_group_portfolios . new ( new_pg ) . save flash [ :notice ] = "Product added." end end end end @portfolio . update_attributes ( params [ :portfolio ] ) flash [ :notice ] = "Portfolio updated" redirect_to edit_portfolio_path ( @portfolio . id ) end
Adds new product to the portfolio if one is supplied, removes any which were marked for removal.
Adds new product to the portfolio if one is supplied removes any which were marked for removal .