开发者

how can I run Rack::Static only if it starting in production env?

开发者 https://www.devze.com 2023-02-14 11:50 出处:网络
I have a config.ru for Rails 3.0.5 app like this :开发者_Go百科 require ::File.expand_path(\'../config/environment\',__FILE__)

I have a config.ru for Rails 3.0.5 app like this :开发者_Go百科

require ::File.expand_path('../config/environment',  __FILE__)
use Rack::Static, :urls => ['/uploads'], :root => 'tmp'

run newapp::Application

but I want to exec the use Rack::Static, :urls => ['/uploads'], :root => 'tmp' line if and only if Rails start in production.

How can I do it ? Thanks in advance luca


Instead of doing this in your config.ru you can do it in your environment, so in production.rb add this:

config.middleware.use Rack::Static, :urls => ['/uploads'], :root => 'tmp'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号