0

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"]

3
  • 1
    Rename "Videos" to "videos". Postgresql is case sensitive for quoted names. More details: stackoverflow.com/questions/21796446/postgres-case-sensitivity Commented Mar 28, 2019 at 6:40
  • 1
    can you share the migration file for "videos"? Commented Mar 28, 2019 at 8:38
  • 1
    It was a case sensitive problem, thank you! If you would like to make this comment an answer I would gladly mark it as the right answer. Commented Mar 28, 2019 at 17:38

1 Answer 1

1

Rename "Videos" table to "videos".

In PostgreSQL unquoted names are case-insensitive. Thus SELECT * FROM videos and SELECT * FROM ViDeOs are equivalent.

However, quoted names are case-sensitive. SELECT * FROM "videos" is not equivalent to SELECT * FROM "Videos".

More details here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.