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: = self.class..new .file = params[:file] if .save and params[:container_id] != 'null' begin container = params[:container_model].classify.constantize.find params[:container_id] associate(container, params[:method]) container.save rescue .uploading_error end end if .errors.any? succeed = false data = .errors..values.flatten .destroy else succeed = true data = .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: .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 .full_file_path, :type => .mimetype, :filename => .filename end |