Sha256: c758bdcefcb6c4a25d01cae5a60b3f15b46f84de7e4a74e037196466097e571c

Contents?: true

Size: 1.34 KB

Versions: 11

Compression:

Stored size: 1.34 KB

Contents

module ActiveMetadata
  class AttachmentsController < ApplicationController

    unloadable

    def index
       @document = eval(params[:model_name]).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 = eval(params[:model_name]).find params[:model_id]
      @document.save_attachment_for(params[:field_name], params[:file])
      
      #todo: if errors send back the correct answer
      respond_to do |format|
        format.js {render :json => {'success' => true}}
      end
    end

    def update
      @document = eval(params[:model_name]).find params[:model_id]
      @document.update_attachment_for(params[:field_name],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 = eval(params[:model_name]).find params[:model_id]
      @document.delete_attachment_for(params[:field_name], 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

11 entries across 11 versions & 1 rubygems

Version Path
active_metadata-0.4.2 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.4.1 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.3.2 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.3.1 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.3.0 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.2.4 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.2.3 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.2.2 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.2.1 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.2.0 app/controllers/active_metadata/attachments_controller.rb
active_metadata-0.1.9 app/controllers/active_metadata/attachments_controller.rb