This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# acid-template.rb | |
git :init | |
gitignore = run("curl https://gist.github.com/raw/3875160/5d2745ee9bcae0bb4addf4bc701d3fa9a48ce187/.gitignore") | |
file ".gitignore", gitignore | |
if yes?("Do you use RVM? (yes|no") | |
if yes?("Do you want to create a .rvmrc file for the project? (yes|no)") | |
# RVM | |
current_ruby = %x{rvm list}.match(/^=>\s+(.*)\s\[/)[1].strip | |
desired_ruby = ask("Which RVM Ruby would you like to use? [#{current_ruby}]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
group :test do | |
gem "database_cleaner" | |
end | |
# spec/support/database_cleaner.rb | |
RSpec.configure do |config| | |
DatabaseCleaner.strategy = :truncation | |
config.before(:each) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/spec_helper.rb | |
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } | |
# spec/support/devise.rb | |
RSpec.configure do |config| | |
config.include Devise::TestHelpers, type: :controller | |
end | |
# spec/controllers/whatever/controller/that/needs/authentication.rb | |
before :each do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------------ | |
# Returncode. | |
#------------------------------------------------------------------------------ | |
function returncode | |
{ | |
returncode=$? | |
if [ $returncode != 0 ]; then | |
echo "[$returncode]" | |
else | |
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------------------------------------- | |
# Ignore these files when commiting to a git repository | |
# | |
# The original version of this file is found here: | |
# https://github.com/RailsApps/rails3-application-templates/raw/master/files/gitignore.txt | |
# | |
# Corrections? Improvements? Create a GitHub issue: | |
# http://github.com/RailsApps/rails3-application-templates/issues | |
#---------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pg_dump -Fc | gzip -9 -c > dumpfile.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/rack/revision.rb | |
module Rack | |
class Revision | |
@@revision = nil | |
File = ::File | |
def initialize(app, &block) | |
@app = app | |
@block = block | |
@file = File.join(Dir.pwd, 'REVISION') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2 | |
tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2 | |
mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf | |
chmod +x /usr/local/bin/wkhtmltopdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This gist outlines a generic implementation of multistage deployment with Capistrano for Rails 3.1+. | |
# | |
# Usage: | |
# | |
# cap #{stage} deploy:setup | |
# cap #{stage} deploy:cold | |
# cap #{stage} deploy | |
# | |
# etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ModuleName | |
extend ActiveSupport::Concern | |
module InstanceMethods | |
def destroy | |
run_callbacks :destroy do | |
if self.respond_to? :deleted | |
self.deleted = true | |
self.save(validate: false) | |
else | |
raise "deleted attribute not found in model" |
NewerOlder