Skip to content

Instantly share code, notes, and snippets.

@vincentmilliken
Created February 2, 2013 12:03
Show Gist options
  • Save vincentmilliken/4697023 to your computer and use it in GitHub Desktop.
Save vincentmilliken/4697023 to your computer and use it in GitHub Desktop.
Sinatra Heroku App
require 'rubygems'
require 'sinatra'
require 'data_mapper'
Dir['vendor/*'].each do |lib|
$:.unshift(File.join(File.dirname(__FILE__), lib, 'lib'))
end
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/recall.db")
# DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/recall.db")
# DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://localhost/recall.db')
class Note
include DataMapper::Resource
property :id, Serial
property :content, Text, :required => true
property :complete, Boolean, :required => true, :default => 0
property :created_at, DateTime
property :updated_at, DateTime
end
DataMapper.finalize
DataMapper.auto_upgrade!
get '/' do
@notes = Note.all :order => :id.desc
@title = 'All Codes'
erb :home
end
post '/' do
n = Note.new
n.content = params[:code]
n.created_at = Time.now
n.updated_at = Time.now
n.save
redirect '/'
end
get '/:id' do
@note = Note.get params[:id]
@title = "Edit Cdoe ##{params[:id]}"
erb :edit
end
put '/:id' do
n = Note.get params[:id]
n.content = params[:code]
n.complete = params[:complete] ? 1 : 0
n.updated_at = Time.now
n.save
redirect '/'
end
get '/:id/delete' do
@note = Note.get params[:id]
@title = "Confirm deletion of note ##{params[:id]}"
erb :delete
end
delete '/:id' do
n = Note.get params[:id]
n.destroy
redirect '/'
end
get '/:id/complete' do
n = Note.get params[:id]
n.complete = n.complete ? 0 : 1 # flip it
n.updated_at = Time.now
n.save
redirect '/'
end
require 'sinatra'
require './application'
run Sinatra::Application
source :rubygems
gem 'sinatra'
gem 'compass'
gem 'haml'
gem 'sass'
gem 'rake'
gem 'data_mapper'
gem 'dm-core'
gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development
gem 'dm-timestamps'
gem 'dm-validations'
gem 'dm-aggregates'
gem 'dm-migrations'
gem 'haml'
2013-02-02T11:52:58+00:00 heroku[api]: Enable Logplex by vincentamilliken@gmail.com
2013-02-02T11:52:58+00:00 heroku[api]: Release v2 created by vincentamilliken@gmail.com
2013-02-02T11:54:01+00:00 heroku[slugc]: Slug compilation started
2013-02-02T11:54:38+00:00 heroku[api]: Scale to web=1 by vincentamilliken@gmail.com
2013-02-02T11:54:38+00:00 heroku[api]: Add config by vincentamilliken@gmail.com
2013-02-02T11:54:38+00:00 heroku[api]: Release v3 created by vincentamilliken@gmail.com
2013-02-02T11:54:38+00:00 heroku[api]: Release v4 created by vincentamilliken@gmail.com
2013-02-02T11:54:39+00:00 heroku[api]: Deploy f9374f5 by vincentamilliken@gmail.com
2013-02-02T11:54:39+00:00 heroku[slugc]: Slug compilation finished
2013-02-02T11:54:42+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 17549`
2013-02-02T11:54:42+00:00 app[web.1]: bash: bundle: command not found
2013-02-02T11:54:44+00:00 heroku[web.1]: Process exited with status 127
2013-02-02T11:54:44+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 20950`
2013-02-02T11:54:46+00:00 app[web.1]: from /app/config.ru:in `new'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/config.ru:in `<main>'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:250:in `start'
2013-02-02T11:54:46+00:00 app[web.1]: /app/config.ru:3:in `require': no such file to load -- ./application (LoadError)
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:49:in `new_from_string'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/config.ru:3:in `block in <main>'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:55:in `instance_eval'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:49:in `eval'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `<main>'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:277:in `build_app_and_options_from_config'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:199:in `app'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:314:in `wrapped_app'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:141:in `start'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:40:in `parse_file'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `load'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:55:in `initialize'
2013-02-02T11:54:46+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/bin/rackup:4:in `<top (required)>'
2013-02-02T11:54:47+00:00 heroku[web.1]: Process exited with status 1
2013-02-02T11:54:47+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-02T11:54:47+00:00 heroku[web.1]: State changed from crashed to starting
2013-02-02T11:54:49+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 11297`
2013-02-02T11:54:51+00:00 app[web.1]: from /app/config.ru:3:in `block in <main>'
2013-02-02T11:54:51+00:00 app[web.1]: /app/config.ru:3:in `require': no such file to load -- ./application (LoadError)
2013-02-02T11:54:51+00:00 app[web.1]: from /app/config.ru:in `<main>'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:40:in `parse_file'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:55:in `instance_eval'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:49:in `new_from_string'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:314:in `wrapped_app'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:141:in `start'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:277:in `build_app_and_options_from_config'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:199:in `app'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/bin/rackup:4:in `<top (required)>'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/server.rb:250:in `start'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:55:in `initialize'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/config.ru:in `new'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.1/lib/rack/builder.rb:49:in `eval'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `load'
2013-02-02T11:54:51+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `<main>'
2013-02-02T11:54:52+00:00 heroku[web.1]: Process exited with status 1
2013-02-02T11:54:52+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-02T11:54:53+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=codebracket.herokuapp.com fwd=86.169.204.153 dyno= queue= wait= connect= service= status=503 bytes=
2013-02-02T11:54:54+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=codebracket.herokuapp.com fwd=86.169.204.153 dyno= queue= wait= connect= service= status=503 bytes=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment