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 SeedFu | |
class Seeder | |
private | |
def seed_record(data) | |
record = find_or_initialize_record(data) | |
return if @options[:insert_only] && !record.new_record? | |
puts " - #{@model_class} #{data.inspect}" unless @options[:quiet] | |
# Rails 3 or Rails 4 + rails/protected_attributes |
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 AfterCommitCallbacks | |
def self.included(base) | |
base.send(:extend, ObserverCallbacks) unless base.respond_to?(:define_model_callbacks_for_observers) | |
[:create, :update, :destroy].each do |action| | |
base.send(:define_model_callbacks_for_observers, :"commit_on_#{action}", :only => :after) | |
end | |
base.send(:attr_accessor, :newly_created) | |
base.send(:before_save, AfterCommitCallbacks::Handlers) |
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 AfterCommitCallbacks | |
def self.included(base) | |
base.send(:extend, ObserverCallbacks) unless base.respond_to?(:define_model_callbacks_for_observers) | |
[:create, :update, :destroy].each do |action| | |
base.send(:define_model_callbacks_for_observers, :"commit_on_#{action}", :only => :after) | |
end | |
base.send(:attr_accessor, :newly_created) | |
base.send(:before_validation, AfterCommitCallbacks::Handlers) |
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
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |