suite
This commit is contained in:
parent
bc9e6945e7
commit
6792d2df62
14
app/controllers/download_contact_files_controller.rb
Normal file
14
app/controllers/download_contact_files_controller.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
class DownloadContactFilesController < ApplicationController
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def show
|
||||||
|
@data_file = ContactFile.find_by_token(params[:id])
|
||||||
|
send_file @data_file.file.path #, :disposition => "inline"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
@ -13,4 +13,14 @@ class ContactFile < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
before_create { generate_token() }
|
||||||
|
|
||||||
|
def generate_token()
|
||||||
|
begin
|
||||||
|
self[:token] = SecureRandom.urlsafe_base64
|
||||||
|
end while ContactFile.exists?(:token => self[:token])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ class ContactFileUploader < CarrierWave::Uploader::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"/download_data_files/#{model.token}"
|
"/download_contact_files/#{model.token}"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ CMSnb::Application.routes.draw do
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
resources :download_contact_files
|
||||||
|
|
||||||
resources :download_data_files
|
resources :download_data_files
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user