【发布时间】:2012-05-22 00:20:06
【问题描述】:
我有一个 Rails 应用程序(版本 3.2.3),我想提供一些故意不在公共目录中的静态文件。这个应用程序只是一个正在进行的工作,我只是用它来比较我在开发过程中的反应。
我设置了以下 mini Rack 应用程序,我正在使用 Rails 自动加载:
APISchemaSampleServer = Proc.new do |env|
Rack::Directory.new(Rails.root + "/spec/support/schema_definitions")
end
在我的路由文件中,我安装了小型 Rack 应用程序:
mount APISchemaSampleServer, at: '/samples'
我在 spec/support/schema_definitions 的目录是一个现有目录,其中有几个文件,当我在 Rails 应用程序中浏览 /samples 时,我想提供这些文件。
访问上述路径时,出现以下错误:
NoMethodError
undefined method `[]' for nil:NilClass
我一直在浏览Rack::Directory documentation 并尝试了几种不同的方法,但这似乎仍然不起作用。
非常感谢任何帮助。提前谢谢你。
【问题讨论】:
标签: ruby-on-rails rack