diff --git a/README.md b/README.md index 4d0a0567c..c258351bf 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,29 @@ for you. Checkout [Hoptoad](http://hoptoadapp.com) from the guys over at cap deploy:setup deploy +**Deploying to Heroku:** + + 1. Clone the repository + + git clone http://github.com/jdpace/errbit.git + + 2. Create & configure for Heroku + + gem install heroku + heroku create + heroku addons:add mongohq:free + heroku addons:add sendgrid:free + heroku config:add HEROKU=true + heroku config:add ERRBIT_HOST=some-hostname.example.com + heroku config:add ERRBIT_EMAIL_FROM=example@example.com + git push heroku master + + 3. Seed the DB (_NOTE_: No bootstrap task is used on Heroku!) + + heroku rake db:seed + + 4. Enjoy! + TODO ---- diff --git a/config/initializers/_load_config.rb b/config/initializers/_load_config.rb index 1e9626533..e52b66113 100644 --- a/config/initializers/_load_config.rb +++ b/config/initializers/_load_config.rb @@ -1,11 +1,18 @@ require 'ostruct' -yaml = File.read(Rails.root.join('config','config.yml')) -config = YAML.load(yaml) +if ENV['HEROKU'] + Errbit::Config = OpenStruct.new + Errbit::Config.host = ENV['ERRBIT_HOST'] + Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM'] + Errbit::Config.email_at_notices = [1,3,10] #ENV['ERRBIT_EMAIL_AT_NOTICES'] +else + yaml = File.read(Rails.root.join('config','config.yml')) + config = YAML.load(yaml) -config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env) + config.merge!(config.delete(Rails.env)) if config.has_key?(Rails.env) -Errbit::Config = OpenStruct.new(config) + Errbit::Config = OpenStruct.new(config) +end # Set config specific values ActionMailer::Base.default_url_options[:host] = Errbit::Config.host \ No newline at end of file diff --git a/config/initializers/mongo.rb b/config/initializers/mongo.rb new file mode 100644 index 000000000..f064bcfdf --- /dev/null +++ b/config/initializers/mongo.rb @@ -0,0 +1,9 @@ +if ENV['MONGOHQ_URL'] + settings = URI.parse(ENV['MONGOHQ_URL'] || 'mongodb://localhost/sushi') + database_name = settings.path.gsub(/^\//, '') + + Mongoid.configure do |config| + config.master = Mongo::Connection.new(settings.host, settings.port).db(database_name) + config.master.authenticate(settings.user, settings.password) if settings.user + end +end \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index bc576ef14..87fca0285 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -14,8 +14,8 @@ :name => 'Errbit Admin', :email => admin_email, :password => admin_pass, - :password_confirmation => admin_pass, + :password_confirmation => admin_pass }) user.admin = true -user.save! \ No newline at end of file +user.save!