2
在rake任務之前或之後添加RAILS_ENV
之間的區別是什麼?以下是我的演出環境中的示例:在rake任務之前或之後添加RAILS_ENV之間的區別
在耙取任務後添加
RAILS_ENV
。這提出了一個錯誤,其原因是默認接受
development
環境,而不是以devutility
作爲環境。$bundle exec rake -T RAILS_ENV=devutility $rake aborted! $cannot load such file -- rack/bug
rake任務
這工作,並列出了所有耙任務可用之前添加
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 .................... ..............
好的,但是你知道爲什麼當它放在耙子任務的最後時它會以一種奇怪的方式表現嗎? – AnkitG
是的,因爲你運行rake任務,然後*設置RAILS_ENV,所以它在運行rake時沒有設置。 – jordelver
@AnkitG對你有幫助嗎? – jordelver