February 2012
2 posts
Array#uniq in Ruby 1.8.7
On github: https://gist.github.com/1905081
class Equal
attr_accessor :name
def initialize(name)
@name = name
end
def inspect
@name
end
def hash
puts "#{name}: hash"
super
end
def eql?(co)
puts "#{name}: eql? against #{co.name}"
super
end
def ==(co)
puts "#{name}: == against #{co.name}"
super
end
end
EqualA = Equal.new('EqualA')
EqualB =...
Autoloading in Rails 3
Rails 3 by default adds these to the autoload paths:
app/*
vendor/plugins/*/lib
vendor/plugins/*/app/*
In addition, gems, when they are defined as Rails engines/railties, get each directory in app added to the autoload path.
Notable exceptions: Rails does not automatically add its own lib directory or the lib directories of any plugins to the load path.
September 2011
1 post
Asset fallback paths in Rails 3.1
Many things can cause your production asset paths to change. When that happens, your previous assets just stop working at all. Moreover, it seems like it would make sense for the bare asset path (without the md5 postfix) should just point to the most recent version of the asset. This little tidbit should take care of all of that.
Myapp::Application.routes.draw do
match 'assets/:id.:format'...
March 2011
1 post