I'm following this guide, https://devcenter.heroku.com/articles/getting-started-with-rails5. I take out the 'sqlite3' gem and add 'pg', then run bundle install. Then I change my config/database.yml file to look like the following
config/database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: myapp5_development
test:
<<: *default
database: myapp5_test
production:
<<: *default
database: myapp5_production
username: myapp5
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
For the next part, the guide gives me two choices and I have tried both. Installing this gem 'rails_12factor' or add the following code to my 'config/environments/production.rb' file
config/environments/production.rb
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Then if I run rake db:create followed by rake db:migrate it gives me errors so I run rake db:reset and that lets the migrations run through. If I start up my site I get the error
PG::UndefinedTable: ERROR: relation "videos" does not exist
LINE 1: SELECT "videos".* FROM "videos" ORDER BY "videos"."title" A...
^
: SELECT "videos".* FROM "videos" ORDER BY "videos"."title" ASC LIMIT $1 OFFSET $2
Extracted source (around line #2):
<div class="container">
<% @videos.each do |x| %>
<p> <div class="child">
<video controls width="310" height="230" src="<%= x.file %>"></video>
<p> <%= x.title %> </p>
When I take a look at my tables through ActiveRecord::Base.connection.tables I see that videos exists.
["Videos", "ipaddresstrackers", "users", "votes", "schema_migrations", "ar_internal_metadata"]