How can I make rake tasks run in an environment other than dev?

后端 未结 2 507
迷失自我
迷失自我 2021-01-14 07:47

I have a staging machine with a special \"staging\" environment. I always forget to run rake tasks on that machine like:

rake jobs:work RAILS_ENV=staging


        
相关标签:
2条回答
  • 2021-01-14 07:56
    Rails.env = 'staging'
    

    Put this in your task file.

    0 讨论(0)
  • 2021-01-14 08:12

    You can put a line that sets the environment variable RAILS_ENV in a file that will get run when you log onto the machine. For example, I'm a bash user, so I'd put the line

    export RAILS_ENV=staging
    

    In either ~/.bashrc (just for me) or /etc/bashrc (for everyone who logs onto the machine).

    Hope this helps!

    0 讨论(0)
提交回复
热议问题