rails admin - Rails_admin and paperclip : File out of public folder, how to download? -
i'm using last rails_admin gem , paperclip.
i save attachment folder not accessible browser.
my model :
class mymodel < activerecord::base has_attached_file :file, :path => ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" end but know can't retrieve file rails_admin. when click on link have :
no route matches [get] "/system/files/20/original/my_pdf.pdf" it's normal because file isn't in public folder.
do know solution ? of course tried set :url.
you won't able serve normal file / asset. you'll want create new controller#action sending file via send_file, e.g.
class downloadscontroller < applicationcontroller def show item = product.find(params[:id]) if current_user.downloads.include?(item) send_file "#{rails.root}/#{item.downloadable.url(:default, false)}" else redirect_to(root_url, :notice => "you not have access content.") end end end this grabbed blog article here, , common sending files not stored in public/ root downloadable purchased files.
an alternative option here create symlink serve file(s), skip authorization step, if needed.
Comments
Post a Comment