Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.58 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class PaintingsController < ApplicationController
  2.  
  3.   def index
  4.     @pictures = Painting.all
  5.     render :json => @pictures.collect { |p| p.to_jq_upload }.to_json
  6.   end
  7.   def managefiles
  8.     @title = ' - Manage Files'
  9.     @folder = Painting.select("DISTINCT folder").order("folder ASC, name ASC")
  10.     @allfiles = Painting.select("folder, name, id").order("name ASC, name ASC")
  11.     #@allfiles = Painting.select("folder, name, id").order("name DESC")
  12.   end  
  13.   def destroy_multiple
  14.    #@files = Painting.find(params[:id])
  15.    #for file in @files
  16.    #    file.destroy
  17.    #end
  18.    if params[:fid].blank?
  19.     @folder = Painting.select("DISTINCT folder").order("folder ASC, name ASC")
  20.     @allfiles = Painting.select("folder, name, id").order("name ASC, name ASC")
  21.     flash.now[:notice] = "Error Deleting File(s)!"
  22.    else
  23.    Painting.find(params[:fid]).each { |f| f.destroy }
  24.     @folder = Painting.select("DISTINCT folder").order("folder ASC, name ASC")
  25.     @allfiles = Painting.select("folder, name, id").order("name ASC, name ASC")
  26.     flash.now[:notice] = "File(s) Deleted!"
  27.    end
  28.   end
  29.   def searchcatalog
  30.     @folder = Painting.select("DISTINCT folder").order("folder ASC, name ASC")
  31.     @allfiles = Painting.select("folder, name, id").order("name ASC, name ASC")
  32.     #@folder = Painting.select("DISTINCT folder").where("folder like %?% or name like %?%", params[:catalog_search], params[:catalog_search]).order("folder ASC, name ASC")
  33.     #@allfiles = Painting.select("folder, name, id").where("folder like %?% or name like %?%", params[:catalog_search], params[:catalog_search]).order("name ASC, name ASC")
  34.   end
  35. end