开发者

What is the correct way to run a custom ruby script from inside the script directory from Rails application? (Production environment)

开发者 https://www.devze.com 2023-01-11 03:57 出处:网络
link text I tried all of the answers from the above stack overflow post but none of them worked When I replace the#!/usr/bin/env ruby with the #!/path/to/my/script/runner and try to run

link text

I tried all of the answers from the above stack overflow post but none of them worked

When I replace the #!/usr/bin/env ruby with the #!/path/to/my/script/runner and try to run

Rails returns:

/var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in establish_connection': Please install the postgresql adapter:gem install开发者_如何学Go activerecord-postgresql-adapter(no such file to load -- pg) (RuntimeError) from /var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:inestablish_connection' etc. . . .

when I leave the original shebang #!/usr/bin/env ruby intact, no combination of commands work.

e.g. script/my_script -e production returns:

/var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified) from /var/www/cmgmail/production/releases/20100810151610/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:inestablish_connection' ...etc

./my_script returns: ./my_script: No such file or directory (yet I verified the file is there)

is there something obvious I am missing?

I suppose I can make this into a rake task but this script runs fine in dev mode.


Don't forget to run chmod a+x my_script. By the way, try running script/my_script with the RAILS_ENV=production environment variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消