Firstly, lets add the heroku-postgresql addon to our project.
heroku addons:add heroku-postgresql
Add Postgres to the Gemfile for Production
gem 'data_mapper'
group :production do
gem 'pg'
gem 'dm-postgres-adapter'
end
and SQLite for Development
group :development do
gem 'sqlite3'
gem 'dm-sqlite-adapter'
end
and install
Did you know? You type bundle
rather then bundle install
as it will run the install task by default.
bundle
This will fail in you don't have Postgres installed. Install it with:
brew install postgresql
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
I also recommend installing a Postgres GUI such as pgAdmin
http://www.pgadmin.org/download/macosx.php
Add this just under the require statements in the cocktail_api.rb file.
require 'data_mapper'
class Drink
include DataMapper::Resource
property :id, Serial
property :name, String
end
configure do
DataMapper.setup(:default, (ENV["DATABASE_URL"] || "sqlite3:///#{Dir.pwd}/development.sqlite3"))
DataMapper.auto_upgrade!
end