Permalink
Browse files

better error reporting and handle has_and_belongs_to_many

  • Loading branch information...
1 parent db06979 commit 2dff58a1b829c6b8df172e2203888286c4281d5d @jackdempsey jackdempsey committed with Sep 17, 2010
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/rails_admin/active_record_support.rb
@@ -106,10 +106,10 @@ def association_parent_model_lookup(association)
case association.macro
when :belongs_to
association.klass
- when :has_one, :has_many
+ when :has_one, :has_many, :has_and_belongs_to_many
association.active_record
else
- raise "Unknown association type"
+ raise "Unknown association type: #{association.macro.inspect}"
end
end
@@ -121,21 +121,21 @@ def association_child_model_lookup(association)
case association.macro
when :belongs_to
association.active_record
- when :has_one, :has_many
+ when :has_one, :has_many, :has_and_belongs_to_many
association.klass
else
- raise "Unknown association type"
+ raise "Unknown association type: #{association.macro.inspect}"
end
end
def association_child_key_lookup(association)
case association.macro
when :belongs_to
["#{association.class_name.underscore}_id".to_sym]
- when :has_one, :has_many
+ when :has_one, :has_many, :has_and_belongs_to_many
[association.primary_key_name.to_sym]
else
- raise "Unknown association type"
+ raise "Unknown association type: #{association.macro.inspect}"
end
end

0 comments on commit 2dff58a

Please sign in to comment.