0

Working on lessons learning Rails online. I run the following commands --

set RAILS_ENV=production

bundle exec rake assets:precompile

This is the error I get --

rake aborted! ActiveRecord::AdapterNotSpecified: 'postgresql' database is not configured. Avai lable: ["default", "development", "test", "production", "adapter", "database", " encoding", "min_messages", "pool", "timeout"] C:/Users/username/work/stukdo/config/environment.rb:5:in `' Tasks: TOP => environment (See full trace by running task with --trace

My gemfile has the following:

group :development, :test do
gem 'spring'
gem 'sqlite3'
end

group :production do
gem 'rails_12factor'
gem 'pg'
end 

...and here's my database.yml file:

default: &default
adapter: sqlite3
pool: 5
timeout: 5000

development:
<<: *default
database: db/development.sqlite3

test:
<<: *default
database: db/test.sqlite3

production: &default
adapter: postgresql
database: todoism
encoding: utf8
min_messages: warning
pool: 5
timeout: 5000

Any ideas? I'm following the lesson exactly. I'm trying to precompile these files before uploading them to heroku.

1
  • Please post your /config/environment.rb file Commented Mar 13, 2015 at 13:59

2 Answers 2

1

Files should look like this:

gemfile

source 'https://rubygems.org'

group :development, :test do
  gem 'spring'
  gem 'sqlite3'
end

group :production do
  gem 'rails_12factor'
  gem 'pg'
end 

/config/database.yml

development:
  adapter:  postgresql
  host:     localhost
  encoding: utf8
  database: todoism
  pool:     5
  username: <%= ENV['PG_USERNAME'] %>
  password: <%= ENV['PG_PASSWORD'] %>
  template: template0
  # others options

test:
   adapter:  postgresql
   host:     127.0.0.1
   encoding: utf8
   database: todoism
   pool:     5
   username: <%= ENV['PG_USERNAME'] %>
   password: <%= ENV['PG_PASSWORD'] %>
   template: template0
   # others options

production:
  adapter:  postgresql
  host:     127.0.0.1
  encoding: utf8
  database: todoism
  pool:     5
  username: <%= ENV['PG_USERNAME'] %>
  password: <%= ENV['PG_PASSWORD'] %>
  template: template0
  # others options
Sign up to request clarification or add additional context in comments.

Comments

1

You have to move that last chunk of code in your database.yml file:

production:
  adapter: postgresql
  database: todoism
  encoding: utf8
  pool: 5
  timeout: 5000
  username: YOUR USERNAME
  password: <%= ENV['THE DATABASE PASSWORD YOU CONFIGURED ON HEROKU'] %>

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.