Rails 在不同部署环境下需要采用不同的代码逻辑,该如何实现?

alucardpj · March 08, 2012 · Last by alucardpj replied at March 08, 2012 · 2460 hits

比方说下载文件,develop 环境下为了简单,直接 link_to 下载地址或者 send_file 输出文件流都可以,但是放到部署环境里,我希望采用 web 前端服务器代理的方式,如 apache 的 x-sendfle 头或者 nginx 的 X-Accel-Redirect 头这种,这两种部署环境下代码逻辑是不一样的,怎样在代码中区分呢?

if Rails.env == "production"
else
end

You need to Sign in before reply, if you don't have an account, please Sign up first.