Changeset 31

Show
Ignore:
Timestamp:
06/03/2007 07:57:38 PM (2 years ago)
Author:
matthew
Message:

Array#to_label returns a comma-separated list of its members' labels.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/auto-admin/init.rb

    r23 r31  
    3232  end 
    3333end 
     34 
     35# We want AssociationProxy to forward #to_label on to its target, but 
     36# because we're adding the above to Object after AssociationProxy 
     37# flushes its instance methods, we have to do it manually. 
     38ActiveRecord::Associations::AssociationProxy.send :undef_method, :to_label 
     39 
     40class ::Array; def to_label; map {|m| m.to_label }.join(', '); end; end 
    3441class ::TrueClass; def to_label; 'Yes'; end; end 
    3542class ::FalseClass; def to_label; 'No'; end; end