def admin_group_variants
      @product = Product.find(params[:id])
      
      return if !user_is_allowed('variants', 'edit')
      
      joins  = []
      where  = []
      values = []
      
      if params[:category_ids]
        joins  << [:category_memberships]
        where  << 'store_category_memberships.category_id IN (?)'
        values << params[:category_ids]
      end
      
      if params[:vendor_ids]
        joins  << [:vendor]
        where  << 'store_vendors.id IN (?)'
        values << params[:vendor_ids]
      end
      
      if params[:title]
        where  << 'LOWER(store_products.title) LIKE ?'
        values << "%#{params[:title].downcase}%"
      end
      
      # Query for all relevant products
      products = values.any? ? Product.joins(joins).where([where.join(' AND ')].concat(values)) : []
      
      # Grab variants for each product
      @variants = products.collect { |product| product.variants }.flatten
      
      # Grab all categories; except for "all" and "uncategorized"
      @categories = Category.where('parent_id IS NOT NULL AND name IS NOT NULL').order(:url)
      
      # Grab all vendors
      @vendors = Vendor.where('name IS NOT NULL').order(:name)
      
      render :layout => 'caboose/admin'
    end
def admin_group_variants
      @product = Product.find(params[:id])
      
      return if !user_is_allowed('variants', 'edit')
      
      joins  = []
      where  = []
      values = []
      
      if params[:category_ids]
        joins  << [:category_memberships]
        where  << 'store_category_memberships.category_id IN (?)'
        values << params[:category_ids]
      end
      
      if params[:vendor_ids]
        joins  << [:vendor]
        where  << 'store_vendors.id IN (?)'
        values << params[:vendor_ids]
      end
      
      if params[:title]
        where  << 'LOWER(store_products.title) LIKE ?'
        values << "%#{params[:title].downcase}%"
      end
      
      # Query for all relevant products
      products = values.any? ? Product.joins(joins).where([where.join(' AND ')].concat(values)) : []
      
      # Grab variants for each product
      @variants = products.collect { |product| product.variants }.flatten
      
      # Grab all categories; except for "all" and "uncategorized"
      @categories = Category.where('parent_id IS NOT NULL AND name IS NOT NULL').order(:url)
      
      # Grab all vendors
      @vendors = Vendor.where('name IS NOT NULL').order(:name)
      
      render :layout => 'caboose/admin'
    end
=============================================================================
 Admin actions
=============================================================================
 GET /admin/products/:id/variants/group