Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **1. Check your Rails version**
- rails -v
- 2. Open the Gemfile and replace the line "gem 'sqlite3" with gem 'pg', '~> 1.0'
- 3. Replace the line with your current Rails version with "gem 'rails', '5.0.6'"
- 4. Run bundle install
- 5. Run bundle update
- 6. Check your current Rails version
- rails -v
- 7. Check if pg is installed
- bundle show
- Now, let's config PostgreSQL
- 8. Respect the indentation and replace with a new code
- default: &default
- adapter: postgresql
- encoding: SQL_ASCII
- pool: 5
- username: ubuntu
- password: password
- development:
- <<: *default
- database: top_development
- test:
- <<: *default
- database: top_test
- production:
- <<: *default
- database: top_production
- by default, your username is "ubuntu", so, just choose a password now and don't forget it.
- Change your database name too.
- 9. Start the PostgresQL service
- sudo service postgresql start
- 10. Enter the Postgreql terminal
- sudo -u postgres psql
- 11. Create the ubuntu user
- CREATE USER ubuntu SUPERUSER PASSWORD 'yourpassword';
- This password must match with your database.yml file.
- 12. Check if you user is already there
- \du
- 13. Create your databases
- CREATE DATABASE "database_name";
- A confirmation message is "Database".
- As always, those database names need to match in Postgres and the database.yml file
- 14. Check all databases in Postgres.
- \l
- Press q to leave.
- 15. Set ubuntu user to become the new owners of the databases
- ALTER DATABASE database_name OWNER TO ubuntu;
- Confirmation message is "ALTER DATABASE".
- 16. Run the \l command again to check if your databases have been owned to ubuntu;
- 17. Press \q to leave postgresql terminal
- 18. Create Rails databases
- Run rails db:create
- If you get a error with your pg gem.
- Just to your gem file and change it to pg (~> 0.18)
- Run bundle install
- then bundle update
- rake db:create
- You'll get a message that they already exist
- 19. Migrate them
- rails db:migrate
- 20. Run the server
- If you get this message:
- Yay! Youβre on Rails!
- Then, you gotta be happy.
- If you don't, check the error message and try again.
- Let me know if I can help you out.
- 21. Way to go!
- You did an amazing job.
Add Comment
Please, Sign In to add comment