在佣金任务之前或之后添加RAILS_ENV
之间的区别是什么?以下是我的登台环境中的示例:
在佣金任务之后添加RAILS_ENV
。
这引发了一个错误,原因是默认情况下接受development
环境,而不是将devutility
作为环境。
$bundle exec rake -T RAILS_ENV=devutility
$rake aborted!
$cannot load such file -- rack/bug
在佣金任务之前添加RAILS_ENV
这适用于并列出了所有可用的佣金任务。
$RAILS_ENV=devutility bundle exec rake -T
rake about # List versions of all Rails frameworks and the environment
rake assets:clean # Remove compiled assets
rake assets:precompile # Compile all the assets named in config.assets.precompile
rake bourbon:install[sass_path] # Move files to the Rails assets directory
rake ci # Continuous Integration build (simplecov-rcov and deploy)
rake cucumber # Alias for cucumber:ok
rake cucumber:all # Run all features
rake cucumber:ok # Run features that should pass
rake cucumber:rerun # Record failing features and run only them if any exist
rake cucumber:wip # Run features that are being worked on
rake db:create # Create the database from DATABASE_URL or config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)
rake db:data:dump ....................
..............
答案 0 :(得分:2)
RAILS_ENV
是一个环境变量,需要才能运行您的佣金任务。
当你这样做时:
RAILS_ENV=devutility bundle exec rake -T
它具有与以下相同的效果:
export RAILS_ENV=devutility
bundle exec rake -T
RAILS_ENV
不是rake
可能出现的参数,它是Ruby可用的环境的一部分,尽管它是ENV
常量。