Created
January 15, 2013 17:44
-
-
Save carlzulauf/4540420 to your computer and use it in GitHub Desktop.
Example irbrc to show using rails or gem specific features when they are available.
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
require 'pp' | |
require 'bigdecimal' | |
File.join(ENV["PWD"],'lib').tap do |lib| | |
if File.directory?(lib) | |
$LOAD_PATH.unshift(lib) unless defined?(Rails) | |
end | |
end | |
class BigDecimal | |
@@auto_round = 3 | |
def self.auto_round=(val) | |
@@auto_round = val | |
end | |
def inspect | |
round(@@auto_round).to_s | |
end | |
end | |
def r | |
require 'redis' unless defined?(Redis) | |
begin | |
Redis.current.tap(&:inspect) # needed to know if connection failed | |
rescue | |
Redis.current = Redis.new(:path => "/tmp/redis.sock") | |
end | |
end | |
if defined?(ActiveRecord::Base) | |
class ActiveRecord::Base | |
def self.sample | |
s = scoped | |
c = s.count | |
s.offset(rand(c)).first | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment