Skip to content

Instantly share code, notes, and snippets.

@danmcclain
danmcclain / capistrano_database_yml.rb
Created August 8, 2011 10:22 — forked from weppos/capistrano_database_yml.rb
Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2010 The Authors
@danmcclain
danmcclain / gist:1135308
Created August 9, 2011 21:57
Refinery Setup from master
rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
rake aborted!
# route.rb has:
# resources :user do
# resources :accounts do
# end
class AccountsController < ApplicationController
before_filter :retrieve_user
respond_to :html, :json
# GET /accounts
@danmcclain
danmcclain / nginx
Created August 27, 2011 12:14 — forked from jordanorelli/nginx
nginx init.d script
#!/usr/bin/env bash
# Adapted from the book "Nginx HTTP Server", by Clement Nedelcu.
# Original Author: Ryuan Norbauer http://norbauerinc.com
# Modified: Geoffrey Grosenbach http://topfunky.com
# Modified: Clement Nedelcu http://cnedelcu.blogspot.com/
# Modified: Jordan Orelli http://jordanorelli.com/
# source: https://gist.github.com/1161075
# Corresponds with the following compile-time options:
scenario 'Logging in' do
ENV["BOSTONRB_ADMIN_NAME"] = name
ENV["BOSTONRB_ADMIN_PASSWORD"] = password
if page.driver.respond_to?(:basic_auth)
page.driver.basic_auth(name, password)
elsif page.driver.respond_to?(:basic_authorize)
page.driver.basic_authorize(name, password)
elsif page.driver.respond_to?(:browser) && page.driver.browser.respond_to?(:basic_authorize)
page.driver.browser.basic_authorize(name, password)
else
@danmcclain
danmcclain / given_when_then-example_spec.rb
Created September 27, 2011 16:40 — forked from bcardarella/given_when_then-example_spec.rb
Given, When, Then pattern applied to Capybara Request DSL
require 'spec_helper'
feature 'Report is Now'
scenario 'with valid attributes' do
Given 'I am authenticated' do
@user = authenticate(create(:user))
end
And 'I have no reports' do
@user.reports.should be_empty
end
#...
has_many :notes_students
has_many :students, through: :notes_students
#...
@danmcclain
danmcclain / devise.rb
Created October 17, 2011 13:10
Devise + Delayed_job
Devise.setup do |config|
#...
config.mailer = "PasswordResetMailer"
#...
end
@danmcclain
danmcclain / delayed_devise_mailer.rb
Created October 20, 2011 11:52 — forked from robotmay/delayed_devise_mailer.rb
A quick hack to make Devise send its confirmation/password reset/unlock emails via delayed_job. Chuck the following in a file under config/initializers
module Devise
module Models
module Confirmable
handle_asynchronously :send_confirmation_instructions
end
module Recoverable
handle_asynchronously :send_reset_password_instructions
end
server {
server_name *.ducky.local ducky.local 127.0.0.1;
root /Projects/Ruby/Rails/duckyg/public;
rack_env development;
passenger_enabled on;
}