当我试图弄清楚如何在Padrino (Carrierwave + Mongoid + gridfs + Padrino admin image upload)中工作的时候,我偶然发现了一些Rails代码,如果我能让它在Padrino中工作的话,它可能会完成这个任务。
假设您有一个在rails中扩展ApplicationController的类,您希望在padrino应用程序+admin中可用.你要把它放在哪里,怎么申报?
#app/controllers/gridfs_controller.rb
class GridfsController < ApplicationController
def serve
gridfs_path = env["PATH_INFO"].gsub("/upload/grid/", "")
begin
gridfs_file = Mongoid::GridFS[gridfs_path]
self.response_body = gridfs_file.data
self.content_type = gridfs_file.content_type
rescue
self.status = :file_not_found
self.content_type = 'text/plain'
self.response_body = ''
end
end
end“服务”应该可以在主应用程序以及帕德里诺管理员。
下面是一个当前状态的回购:https://github.com/bcsantos/debug
发布于 2014-06-17 15:20:02
在IRC聊天之后,这可能会对https://gist.github.com/dariocravero/ab16044bb144bd52513a有所帮助
https://stackoverflow.com/questions/24260381
复制相似问题