Skip to content

Instantly share code, notes, and snippets.

View trevorturk's full-sized avatar

Trevor Turk trevorturk

  • Chicago
View GitHub Profile
# lib/tasks/deploy.rb
desc "deploy to heroku and notify hoptoad"
task :deploy => :environment do
puts "deploying to heroku..."
%x[git push heroku master]
puts "notifying hoptoad..."
rev = %x[git log master -n 1 --pretty=format:%H]
%x[rake hoptoad:deploy TO=production REVISION=#{rev}]
puts "done..."
# Gemfile
source 'http://rubygems.org'
gem 'rails'
group :test do
gem 'capybara'
gem 'launchy'
end
def filter_params(params)
params.inject({}) do |acc, (k, v)|
acc[k] = if v.is_a?(Hash)
filter_params(v)
else
v.is_a?(Tempfile) ? '[REMOVED: Tempfile]' : v
end
acc
end
end
class Post < ActiveRecord::Base
include ActionView::Helpers::TextHelper # truncate
include ERB::Util # h
def to_s
truncate(h(user))
end
end
class Post < ActiveRecord::Base
def link_to_show_people_or_something
host = Rails.application.config.action_mailer.default_url_options[:host]
posts_url(:host => host)
end
end
# config/initializers/delayed_job_mongoid.rb
module Delayed
module Backend
module ActiveRecord
class Job < ::ActiveRecord::Base
def self.before_fork
::ActiveRecord::Base.clear_all_connections!
::Mongoid.master.connection.close
end
log/*.log.*
diff --git c/app/controllers/events_controller.rb w/app/controllers/events_controller.rb
index d7ce126..4e96ab9 100644
--- c/app/controllers/events_controller.rb
+++ w/app/controllers/events_controller.rb
@@ -17,4 +17,8 @@ class EventsController < TdsController
end
end
+ def show
+ @event = Event.find_by_slug! params[:id]
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
# instead of this:
assert_emails do
post :create, :invitation => Invitation.plan
end
# ...do this:
assert_difference 'ActionMailer::Base.deliveries.size' do
post :create, :invitation => Invitation.plan
end