This file contains hidden or 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
From 77883e5358e488d10daa34e8490a6c57b5e0a536 Mon Sep 17 00:00:00 2001 | |
From: Nicolas Blanco <[email protected]> | |
Date: Sat, 7 Aug 2010 22:05:04 +0200 | |
Subject: [PATCH 3/3] Adds basic Capistrano task for Bundler. | |
To use it, just require 'bundler/capistrano' in your Capistrano deploy file (deploy.rb). | |
Bundler will be activated after each new deployment. | |
--- | |
lib/bundler/capistrano.rb | 23 +++++++++++++++++++++++ | |
1 files changed, 23 insertions(+), 0 deletions(-) |
This file contains hidden or 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
# Lets you define relations between ActiveRecord and Mongo objects | |
module MongoRelations | |
module InstanceMethods | |
# get an object representing the MongoMapper equivalent of this object | |
# for the purpose of access relations on the object | |
fattr(:mongo_obj) do | |
res = klass.mongo_class.new | |
my_id = id | |
res.class_eval do |
This file contains hidden or 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
# = Outgoing email settings | |
# | |
# Each environment has it's own configuration options. If you are only | |
# running in production, only the production block needs to be configured. | |
# | |
# == Common configurations | |
# | |
# === Sendmail command | |
# | |
# production: |
This file contains hidden or 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 ActiveRecord::Validations::ClassMethods | |
def validates_uniqueness_of(*attr_names) | |
configuration = { :case_sensitive => true } | |
configuration.update(attr_names.extract_options!) | |
validates_each(attr_names,configuration) do |record, attr_name, value| | |
# The check for an existing value should be run from a class that | |
# isn't abstract. This means working down from the current class | |
# (self), to the first non-abstract class. Since classes don't know | |
# their subclasses, we have to build the hierarchy between self and |
This file contains hidden or 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
# Requires mod_deflate | |
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html |
This file contains hidden or 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
# get rid of the pg if you have it already; you might want to do this for ruby-pg as well | |
gem uninstall pg | |
# change to some convenient working directory | |
cd ~/src | |
svn checkout http://ruby-pg.rubyforge.org/svn | |
cd svn/ruby-pg/trunk/ext | |
# download and install the patch | |
curl -O http://gist.github.com/raw/215956/54166b63f9cce030232b09397934315f004fb649/pg-patch.txt |
This file contains hidden or 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
Warden::Strategies.add(:bcrypt) do | |
def valid? | |
params[:username] || params[:password] | |
end | |
def authenticate! | |
return fail! unless user = User.first(:username => params[:username]) | |
if user.encrypted_password == params[:password] | |
success!(user) |
This file contains hidden or 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
Warden::Strategies.add(:bcrypt) do | |
def valid? | |
params[:username] || params[:password] | |
end | |
def authenticate! | |
return fail! unless user = User.first(:username => params[:username]) | |
if user.encrypted_password == params[:password] | |
success!(user) |
This file contains hidden or 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
# Install | |
# | |
# Move this file into config/preinitializer.rb | |
# | |
# Usage | |
# | |
# This line: | |
# config.github_gem "mislav-will_paginate" | |
# is equivalent to this line: | |
# config.gem "mislav-will_paginate", :lib => "will_paginate", :source => "http://gem.github.com" |
This file contains hidden or 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
class MigrateProductsToPaperclip < ActiveRecord::Migration | |
def self.up | |
# Rename the old "image" column to "old_file_name", since Product.image will now try to do Paperclip stuff | |
rename_column :products, :image, :old_file_name | |
# Rename asset directories to pluralize | |
File.rename("public/system/product","public/system/products") | |
File.rename("public/system/products/image","public/system/products/images") | |