Access denied, Please sign in and make sure you have proper permission.
我把我的代码传到服务器上了,和 development 一模一样,不用做任何修改,服务器就知道是 production 吗?
用原始的/public/index.html 看,参数一目了然。
rails/info/properties
#4 楼 @gazeldx 服务器要通过你设置进去的 rackenv 才知道是跑 production 还是其他的。怎么调要看你用了什么 server。
确定不是?
Rails.env.development? || Rails.env.production?
楼主的识别是从哪里识别,Rails 应用内部就看 Rails.env, 操作系统有环境变量 RAILS_ENV 如项启动 production 的 console 就需要设置环境变量 RAILS_ENV=production rails c,如果是部署环境设置,就看不同的服务器的 config.
感谢各位,特别是#9 楼 @hisea
Production 环境中:
建表:rake RAILS_ENV=production db:schema:load
启动 rails:RAILS_ENV=production unicorn_rails
我把我的代码发布到服务器上,rails 默认的还是 development 的,因此必须加上 RAILS_ENV=production 切换一下
我来补充一下,在当前 project 下
$ rails console
--> Rails.env
就能看到
ENV["RACK_ENV"] 那这个算什么?貌似其他的都是引用的这个常量吧。
在 apache 或者是 nginx 的配置文件中声明一下 rails_env。
或者准确的说,不是识别的,是在启动服务的时候指定的,指定开发环境,还是生产环境。
rails console
Loading development environment (Rails 3.2.13)
1.9.3-p484 :001 > Rails.env
=> "development"
1.9.3-p484 :004 > quit
i# RAILS_ENV=production rails console
Loading production environment (Rails 3.2.13)
1.9.3-p484 :001 > Rails.en
=> "production"
#10 楼 @gazeldx 想问下如果生产环境中想在某个表中加一个属性该怎么加呢!进入后 rails g migration add_area_to_oil 然后 rake db:migrate 只把 area 加到开发环境的数据库中,生成环境还是会报错,不知道怎么弄了,求指点