Class: FlexaDownloadable::DownloadsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/flexa_downloadable/downloads_controller.rb

Instance Method Summary collapse

Instance Method Details

#by_idObject



10
11
12
13
# File 'app/controllers/flexa_downloadable/downloads_controller.rb', line 10

def by_id
  file = FlexaDownloadable::Upload.find_by(file_params)
  exec(file)
end

#downloadObject



5
6
7
8
# File 'app/controllers/flexa_downloadable/downloads_controller.rb', line 5

def download
  file = find_file
  exec(file)
end

#find_fileObject



20
21
22
23
24
25
26
27
# File 'app/controllers/flexa_downloadable/downloads_controller.rb', line 20

def find_file
  id = params[:id].to_i
  klass = params[:klass].classify
  field = params[:field].downcase

  object = eval("::#{klass}.find(#{id})")
  object.send(field)
end

#imageObject



15
16
17
18
# File 'app/controllers/flexa_downloadable/downloads_controller.rb', line 15

def image
  file = FlexaDownloadable::Upload.find_by(file_params)
  exec(file, true)
end