Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rails 2.2 and 2.3 support

  • Loading branch information...
commit 5bdd08a2a1f023b7923bcb0fc3dbfe991a28607c 2 parents 01645c4 + e9c4b86
@aiwilliams authored
Showing with 12 additions and 4 deletions.
  1. +1 −1  CHANGELOG
  2. +11 −3 lib/dataset/record/meta.rb
View
2  CHANGELOG
@@ -1,6 +1,6 @@
*1.3.0 [Rails 2.3.2] (??)
-* Supporting Rails 2.3.2
+* Supporting Rails 2.3.2 [mhawkins, underlog]
*1.2.0 [Cucumber] (April 8, 2009)
View
14 lib/dataset/record/meta.rb
@@ -36,23 +36,31 @@ def timestamp_columns
def id_finder_names
@id_finder_names ||= begin
- names = record_class.self_and_descendants_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_descendants_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 5bdd08a

Please sign in to comment.
Something went wrong with that request. Please try again.