Permalink
Browse files

Fix for the typos in Rails 2.3

  • Loading branch information...
1 parent 9b10a6b commit e9c4b86b5e2f6fa97b3c04b8c9b729c92cac9b8f @underlog underlog committed Apr 14, 2009
Showing with 14 additions and 3 deletions.
  1. +14 −3 lib/dataset/record/meta.rb
View
17 lib/dataset/record/meta.rb
@@ -36,23 +36,34 @@ def timestamp_columns
def id_finder_names
@id_finder_names ||= begin
- names = record_class.self_and_descendents_from_active_record.collect {|c| finder_name c}
+
+ names = descendants.collect {|c| finder_name c}
names.uniq.collect {|n| "#{n}_id".to_sym}
end
end
def model_finder_names
- @record_finder_names ||= record_class.self_and_descendents_from_active_record.collect {|c| finder_name(c).pluralize.to_sym}.uniq
+ @record_finder_names ||= descendants.collect {|c| finder_name(c).pluralize.to_sym}.uniq
end
def to_s
"#<RecordMeta: #{table_name}>"
end
+
+ def descendants
+ if record_class.respond_to?(:self_and_descendents_from_active_record)
+ record_class.self_and_descendents_from_active_record
+ else
+ record_class.self_and_descendants_from_active_record
+ end
+
+ end
+
def finder_name(klass)
klass.name.underscore.gsub('/', '_').sub(/^(\w)_/, '\1').gsub(/_(\w)_/, '_\1')
end
end
end
-end
+end

0 comments on commit e9c4b86

Please sign in to comment.