Guest User

Untitled

a guest
May 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. **1. Check your Rails version**
  2. rails -v
  3.  
  4. 2. Open the Gemfile and replace the line "gem 'sqlite3" with gem 'pg', '~> 1.0'
  5.  
  6. 3. Replace the line with your current Rails version with "gem 'rails', '5.0.6'"
  7.  
  8. 4. Run bundle install
  9.  
  10. 5. Run bundle update
  11.  
  12. 6. Check your current Rails version
  13. rails -v
  14.  
  15. 7. Check if pg is installed
  16. bundle show
  17.  
  18. Now, let's config PostgreSQL
  19.  
  20. 8. Respect the indentation and replace with a new code
  21.  
  22. default: &default
  23. adapter: postgresql
  24. encoding: SQL_ASCII
  25. pool: 5
  26. username: ubuntu
  27. password: password
  28.  
  29. development:
  30. <<: *default
  31. database: top_development
  32.  
  33. test:
  34. <<: *default
  35. database: top_test
  36.  
  37. production:
  38. <<: *default
  39. database: top_production
  40.  
  41. by default, your username is "ubuntu", so, just choose a password now and don't forget it.
  42.  
  43. Change your database name too.
  44.  
  45. 9. Start the PostgresQL service
  46. sudo service postgresql start
  47.  
  48. 10. Enter the Postgreql terminal
  49. sudo -u postgres psql
  50.  
  51. 11. Create the ubuntu user
  52. CREATE USER ubuntu SUPERUSER PASSWORD 'yourpassword';
  53.  
  54. This password must match with your database.yml file.
  55.  
  56. 12. Check if you user is already there
  57. \du
  58.  
  59. 13. Create your databases
  60. CREATE DATABASE "database_name";
  61.  
  62. A confirmation message is "Database".
  63.  
  64. As always, those database names need to match in Postgres and the database.yml file
  65.  
  66. 14. Check all databases in Postgres.
  67. \l
  68.  
  69. Press q to leave.
  70.  
  71. 15. Set ubuntu user to become the new owners of the databases
  72. ALTER DATABASE database_name OWNER TO ubuntu;
  73.  
  74. Confirmation message is "ALTER DATABASE".
  75.  
  76. 16. Run the \l command again to check if your databases have been owned to ubuntu;
  77.  
  78. 17. Press \q to leave postgresql terminal
  79.  
  80. 18. Create Rails databases
  81. Run rails db:create
  82.  
  83. If you get a error with your pg gem.
  84.  
  85. Just to your gem file and change it to pg (~> 0.18)
  86.  
  87. Run bundle install
  88. then bundle update
  89. rake db:create
  90.  
  91. You'll get a message that they already exist
  92.  
  93. 19. Migrate them
  94. rails db:migrate
  95.  
  96. 20. Run the server
  97. If you get this message:
  98. Yay! You’re on Rails!
  99.  
  100. Then, you gotta be happy.
  101. If you don't, check the error message and try again.
  102. Let me know if I can help you out.
  103.  
  104. 21. Way to go!
  105. You did an amazing job.
Add Comment
Please, Sign In to add comment