Class: Renalware::System::DownloadsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- Renalware::System::DownloadsController
- Includes:
- Concerns::Pageable
- Defined in:
- app/controllers/renalware/system/downloads_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
-
#show ⇒ Object
Redirects the uploaded file eg PDF etc.
- #update ⇒ Object
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/renalware/system/downloads_controller.rb', line 21 def create download = Download.new(download_params) download if download.save_by(current_user) redirect_to system_downloads_path, notice: notice else render_new(download) end end |
#destroy ⇒ Object
44 45 46 47 48 |
# File 'app/controllers/renalware/system/downloads_controller.rb', line 44 def destroy download = download.destroy! redirect_to system_downloads_path, notice: notice end |
#edit ⇒ Object
31 32 33 |
# File 'app/controllers/renalware/system/downloads_controller.rb', line 31 def edit render_edit() end |
#index ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/renalware/system/downloads_controller.rb', line 8 def index query = DownloadQuery.new(params[:q]) items = query.call.page(page).per(per_page) items render locals: { items: items, search: query.search } end |
#new ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/renalware/system/downloads_controller.rb', line 15 def new download = Download.new download render_new(download) end |
#show ⇒ Object
Redirects the uploaded file eg PDF etc
51 52 53 54 55 56 57 |
# File 'app/controllers/renalware/system/downloads_controller.rb', line 51 def show download = if download.file.attached? update_view_count_for download redirect_to(raw_active_storage_url_for(download.file)) end end |
#update ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/renalware/system/downloads_controller.rb', line 35 def update download = if download.update_by(current_user, download_params) redirect_to system_downloads_path, notice: notice else render_edit(download) end end |