首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Padrino中的Rails“ApplicationController”?

Padrino中的Rails“ApplicationController”?
EN

Stack Overflow用户
提问于 2014-06-17 09:36:47
回答 1查看 83关注 0票数 0

当我试图弄清楚如何在Padrino (Carrierwave + Mongoid + gridfs + Padrino admin image upload)中工作的时候,我偶然发现了一些Rails代码,如果我能让它在Padrino中工作的话,它可能会完成这个任务。

假设您有一个在rails中扩展ApplicationController的类,您希望在padrino应用程序+admin中可用.你要把它放在哪里,怎么申报?

代码语言:javascript
复制
#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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-17 15:20:02

在IRC聊天之后,这可能会对https://gist.github.com/dariocravero/ab16044bb144bd52513a有所帮助

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24260381

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档