text Cloud9上的Rails + PostgreSQL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Cloud9上的Rails + PostgreSQL相关的知识,希望对你有一定的参考价值。

# https://gist.github.com/eliotsykes/10cf6f1557556e5cafcc857792e63fff

How to setup PostgreSQL & Rails on Cloud9
At time of writing, Cloud9 has PostgreSQL pre-installed, so you won't need to install it yourself. However, its not running by default, so you will need to start it with this command in the terminal:

sudo service postgresql start
Change the PostgreSQL password to 'password' (or choose a different password):

sudo sudo -u postgres psql

# This will open the psql client.

# Type \password and press enter to begin process
# of changing the password:
postgres=# \password

# Type your new password (e.g. "password") and press enter twice:
Enter new password: 
Enter it again: 

# Password changed, quit psql with \q
postgres=# \q 
Edit your config/database.yml to be:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5
  
  # Important configs for cloud9, change password value
  # to what you entered in the previous psql step.
  template: template0
  username: ubuntu
  password: password
  
development:
  <<: *default
  database: your_app_name_development

test:
  <<: *default
  database: your_app_name_test

production:
  <<: *default
  database: your_app_name_production
  username: your_app_name
  password: <%= ENV['YOUR_APP_NAME_DATABASE_PASSWORD'] %>
(Note the template, username, and password configs in the default section above are essential).

Add the pg gem to your Gemfile:

gem 'pg'
Run bundle install.

Remove the sqlite gem from your Gemfile (and optionally delete the db/*.sqlite3 files).

Create the database, load schema.rb, and seed the database using the db:setup task:

bundle exec rake db:setup

# Run bin/rake -AD db to see all db-related tasks
Start or restart your rails app and check it is working.

Note, the non-seed data from your old sqlite database will not be present in the new database.

If you ever want to use the psql client to interact with PostgreSQL directly, in the terminal run psql or run bin/rails db.

以上是关于text Cloud9上的Rails + PostgreSQL的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Cloud9 上的 PHP 5.6 / 7.2 之间切换?

在 Cloud9 终端上的 $PATH 中找不到 lua

脚手架后无法迁移 psql 数据库 - Cloud9

Rails 3.1 实时预览

将 Rails 升级到 6,出现 Blocked host 错误

如何以及在哪里提交 Rails 上的表单值?