Class: Alchemy::Admin::AttachmentsController
- Inherits:
-
ResourcesController
- Object
- ApplicationController
- BaseController
- BaseController
- ResourcesController
- Alchemy::Admin::AttachmentsController
- Includes:
- UploaderResponses
- Defined in:
- app/controllers/alchemy/admin/attachments_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #download ⇒ Object
- #index ⇒ Object
-
#show ⇒ Object
The resources controller renders the edit form as default for show actions.
- #update ⇒ Object
Methods included from UploaderResponses
#failed_uploader_response, #succesful_uploader_response
Methods inherited from ResourcesController
#edit, #new, #resource_handler
Methods included from ResourcesHelper
#contains_relations?, #current_location_params, #edit_resource_path, #new_resource_path, #render_attribute, #render_resources, #resource_attribute_field_options, #resource_filter_select, #resource_has_filters, #resource_has_tags, #resource_instance_variable, #resource_model, #resource_name, #resource_path, #resource_relations_names, #resource_scope, #resource_url_proxy, #resource_window_size, #resources_header, #resources_instance_variable, #resources_path, #sortable_resource_header_column
Methods inherited from BaseController
Methods included from Modules
included, #module_definition_for, register_module
Methods included from Alchemy::AbilityHelper
Methods included from ConfigurationMethods
#configuration, #multi_language?, #multi_site?, #prefix_locale?
Instance Method Details
#create ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 35 def create @attachment = Attachment.new() if @attachment.save render succesful_uploader_response(file: @attachment) else render failed_uploader_response(file: @attachment) end end |
#destroy ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 57 def destroy name = @attachment.name @attachment.destroy @url = ( per_page: params[:per_page], page: params[:page], q: params[:q] ) flash[:notice] = Alchemy.t('File deleted successfully', name: name) end |
#download ⇒ Object
68 69 70 71 72 73 74 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 68 def download @attachment = Attachment.find(params[:id]) send_file @attachment.file.path, { filename: @attachment.file_name, type: @attachment.file_mime_type } end |
#index ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 8 def index @query = Attachment.ransack(params[:q]) @attachments = @query.result if params[:tagged_with].present? @attachments = @attachments.tagged_with(params[:tagged_with]) end if params[:file_type].present? @attachments = @attachments.with_file_type(params[:file_type]) end @attachments = @attachments .page(params[:page] || 1) .per(15) @options = if end end |
#show ⇒ Object
The resources controller renders the edit form as default for show actions.
31 32 33 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 31 def show render :show end |
#update ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/alchemy/admin/attachments_controller.rb', line 44 def update @attachment.update_attributes() render_errors_or_redirect( @attachment, ( per_page: params[:per_page], page: params[:page], q: params[:q] ), Alchemy.t("File successfully updated") ) end |