Module: SimpleAttachments::AttachmentsController::InstanceMethods
- Defined in:
- lib/simple_attachments/attachments_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
:nodoc:.
-
#destroy ⇒ Object
:nodoc:.
-
#show ⇒ Object
:nodoc:.
Instance Method Details
#create ⇒ Object
:nodoc:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/simple_attachments/attachments_controller.rb', line 26 def create # :nodoc: @attachment = self.class..new @attachment.file = params[:file] if @attachment.save and params[:container_id] != 'null' begin container = params[:container_model].classify.constantize.find params[:container_id] associate(container, params[:method]) container.save rescue @attachment.uploading_error end end if @attachment.errors.any? succeed = false data = @attachment.errors..values.flatten @attachment.destroy else succeed = true data = @attachment.serializable_hash end render_answer(succeed, data) end |
#destroy ⇒ Object
:nodoc:
53 54 55 56 |
# File 'lib/simple_attachments/attachments_controller.rb', line 53 def destroy # :nodoc: @attachment.destroy render :nothing => true end |
#show ⇒ Object
:nodoc:
49 50 51 |
# File 'lib/simple_attachments/attachments_controller.rb', line 49 def show # :nodoc: send_file @attachment.full_file_path, :type => @attachment.mimetype, :filename => @attachment.filename end |