Sha256: 8a7e3b39badcc10dbab8c027347fe26a6b7976cc5549b10bbd1742a370cf1b84

Contents?: true

Size: 1.32 KB

Versions: 23

Compression:

Stored size: 1.32 KB

Contents

module ActiveMetadata
  class AttachmentsController < ApplicationController

    def index
      @document = params[:model_name].to_class.find(params[:model_id])
       @attachments = @document.attachments_for params[:field_name]      
       respond_to do |format|
         format.html { render :layout => false}
         format.xml  { render :xml => @histories }
       end
    end  

    def create
      @document = params[:model_name].to_class.find(params[:model_id])
      @document.save_attachment_for(params[:field_name], params[:file], params[:starred], params[:group])
      
      #todo: if errors send back the correct answer
      respond_to do |format|
        format.js {render :json => {'success' => true}}
      end
    end

    def update
      @document = params[:model_name].to_class.find(params[:model_id])
      @document.update_attachment(params[:id],params[:file])
      
      #todo: if errors send back the correct answer
      respond_to do |format|
        format.js {render :json => {'success' => true}}
      end
    end

    def destroy
      @document = params[:model_name].to_class.find(params[:model_id])
      @document.delete_attachment(params[:id])
      
      #todo: if errors send back the correct answer
      respond_to do |format|
        # TODO redirect to index
        format.js
      end
    end

  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_metadata-0.8.9 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.8 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.7.1 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.7 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.6 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.5.2 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.5.1 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.5 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.4 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.3.1 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.3 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.2 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.1 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.8.0 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.7.9 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.7.8 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.7.7 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.7.6 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.7.5 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.7.4 app/controllers/active_metadata/attachments_controller.rb