Class: AmpleAssets::FilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- AmpleAssets::FilesController
- Defined in:
- app/controllers/ample_assets/files_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #gravity ⇒ Object
- #new ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #touch ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/ample_assets/files_controller.rb', line 18 def create if uploadify? filename, filedata = params['Filename'], params['Filedata'] file = File.new(:attachment => filedata) else file = File.new(params[:file]) end if file.save if uploadify? render :nothing => true else redirect_to file_path(file) end else flash[:error] = "Whoops! There was a problem creating new asset." redirect_to :action => :index end end |
#destroy ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/ample_assets/files_controller.rb', line 45 def destroy current_file.destroy if request.xhr? render :nothing => true else flash[:notice] = 'Asset deleted successfully.' redirect_to request.referrer end end |
#gravity ⇒ Object
61 62 63 64 65 |
# File 'app/controllers/ample_assets/files_controller.rb', line 61 def gravity raise ActiveRecord::RecordNotFound if current_file.nil? current_file.update_attribute :attachment_gravity, params[:gravity] render :nothing => true end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/ample_assets/files_controller.rb', line 14 def new render 'ample_assets/files/new', :layout => false, :content_type => :html if request.xhr? end |
#search ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'app/controllers/ample_assets/files_controller.rb', line 67 def search @current_files = File.with_query("^#{params[:q]}") respond_to do |format| format.js { render current_files, :content_type => :html } format.json { render :json => current_files.to_json } format.html { render :nothing => true } end end |
#show ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/controllers/ample_assets/files_controller.rb', line 37 def show raise ActiveRecord::RecordNotFound if current_file.nil? respond_to do |format| format.json { render :json => current_file.to_json } format.html end end |
#touch ⇒ Object
55 56 57 58 59 |
# File 'app/controllers/ample_assets/files_controller.rb', line 55 def touch raise ActiveRecord::RecordNotFound if current_file.nil? current_file.touch render :nothing => true end |