Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/heroku-examples/dbdc-demo

Database.com on Heroku demo app
https://github.com/heroku-examples/dbdc-demo

Last synced: 2 days ago
JSON representation

Database.com on Heroku demo app

Awesome Lists containing this project

README

        

# Database.com Demo App

This app shows how to use the databasedotcom and omniauth gems to interact with data stored on Database.com from a heroku app using the Database.com addon.

## Install

#from your app dir
heroku addons:add database-com
heroku config | grep DATABASE_COM_URL
cp keys.rv keys.rb.sample

*use value from heroku as your ENV var*

bundle install
bundle exec foreman start

## Look, ma. No ActiveRecord!
## (creating models)

To create models, login through the Database.com addon page from your heroku account.

- Create a custom object called "Product"
- call the name field "Name"
- give it a price field
- give it a description field
- give it an image\_url field

Or just delete the ProductController and use your own models!

### Special features

We're using ::const\_missing to allow us to dynamically materialize the Database.com model objects.

## Logging in

OmniAuth is handling the login.
Credentials are stored in the session and a connection is established with Database.com each request.

OmniAuth has a bug that causes it to drop the "s" part of https, so we have to override it in the omniauth initializer.

### Change this in config/initializers/omniauth.rb

if Rails.env.production?
OmniAuth.config.full_host = "https://www.example.com"
end