Skip to content

Instantly share code, notes, and snippets.

View PratheepV's full-sized avatar

Pratheep Velicherla PratheepV

  • Testsigma
  • Bengaluru, India
View GitHub Profile
@PratheepV
PratheepV / seed_fu_enabling_validation_hack.rb
Created September 5, 2015 06:12
To enable validations on seed fu
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
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)
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)
@PratheepV
PratheepV / installation.sh
Created September 11, 2012 05:36 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
# 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