Skip to content

Instantly share code, notes, and snippets.

View divineforest's full-sized avatar

Alexander Balashov divineforest

View GitHub Profile
@thechrisoshow
thechrisoshow / dynamic_validations.rb
Created March 29, 2012 11:56
How to add validations to a specific instance of an active record object?
class Banana < ActiveRecord::Base; end
banana = Banana.new
banana.valid? #=> true
banana.singleton_class.validates_presence_of :name
banana.valid? #=> true - why did the validation not work?
banana.class.validates_presence_of :name
banana.valid? #=> false - as we'd expect...but now...
@julik
julik / unfuck_osx_readline_for_ruby.txt
Created August 24, 2011 13:10
Decent Readline support for irb/pry on Leopard and above for decent UTF8 input, with RVM
Ensure that your ~/.inputrc contains this
set convert-meta off
set input-meta on
set output-meta on
Install the REAL GNU readline from source
$ curl ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz | tar xfz - && cd readline-6.2 && ./configure --enable-multibyte && make && sudo make install
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end