简体   繁体   中英

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

I have a config.ru for Rails 3.0.5 app like this :

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

您可以在您的环境中执行此操作,而不是在您的config.ru中执行此操作,因此在production.rb添加以下内容:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM