我在本地構建了一個小型Rails應用程序,並試圖將其部署到AWS Elastic Beanstalk。如何爲AWS上的Rails應用程序創建數據庫Elastic Beanstalk
這是我一直在下面的指南:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby_rails.html
部署是成功的,但並沒有出現數據庫的播種所以我所有的靜態列表值都是空的。
儘管我不認爲這是「理想」的解決方案,但我確實嘗試通過SSH將數據庫手動播種到EB實例中。
eb ssh
cd /var/app/current/
rake db:seed
,然後將結果是:
[[email protected] current]$ rake db:seed
Rails Error: Unable to access log file. Please ensure that /var/app/current/log/production.log exists and is writable (ie, make it writable for user and group: chmod 0664 /var/app/current/log/production.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
(0.1ms) begin transaction
...
(0.1ms) rollback transaction
rake aborted!
ActiveRecord::StatementInvalid: SQLite3::ReadOnlyException: attempt to write a readonly database: INSERT INTO "users" ("first_name", "last_name", "email", "encrypted_password", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?)
/var/app/current/db/seeds.rb:9:in `<top (required)>'
SQLite3::ReadOnlyException: attempt to write a readonly database
/var/app/current/db/seeds.rb:9:in `<top (required)>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
什麼是做到這一點的正確方法?
在此先感謝!
你會運行'RAILS_ENV =生產rake db:seed',因爲'rake db:seed'將在默認情況下運行開發環境! –
感謝Hieu的建議。我剛剛嘗試過RAILS_ENV =生產rake db:seed並收到完全相同的響應。任何其他想法? –