Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self_and_descendants_from_active_record#nodoc:
- klass = self
- classes = [klass]
- while klass != klass.base_class
- classes << klass = klass.superclass
- end
- classes
- rescue
- # OPTIMIZE this rescue is to fix this test: ./test/cases/reflection_test.rb:56:in `test_human_name_for_column'
- # Appearantly the method base_class causes some trouble.
- # It now works for sure.
- [self]
- end
- def human_name(options = {})
- defaults = self_and_descendants_from_active_record.map do |klass|
- :"#{klass.name.underscore}"
- end
- defaults << self.name.humanize
- I18n.translate(defaults.shift, {:scope => [:activerecord, :models], :count => 1, :default => defaults}.merge(options))
- end
Add Comment
Please, Sign In to add comment