开发者

Access Rails ActiveRecord db in production mode

开发者 https://www.devze.com 2023-04-03 17:32 出处:网络
I\'ve just deployed my first app to production. It\'s a simple front end for managing a DB, and the real action for the app happens in a script I placed in app/ called validation_script.rb.It accesses

I've just deployed my first app to production. It's a simple front end for managing a DB, and the real action for the app happens in a script I placed in app/ called validation_script.rb. It accesses elements in the DB using ActiveRecord and performs actions based on their values. When I was developing, I would test the script by:

rails runner app/validation_script.rb

This ran without any problems on my local machine. But now that I have pushed this onto the hosting server and into production mode, running that same command on the server doesn't access the elements in the ActiveRecord DB. I set my environment in environment.r开发者_JAVA技巧b to ENV['RAILS_ENV'] ||= 'production'. Are there any other settings I'm missing in order to connect to the production DB?


Try this:

rails runner -e production app/validation_script.rb
0

精彩评论

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