Browse files

Merge pull request #769 from bradseefeld/master

Ensure associations is a hash before accessing it like a hash
  • Loading branch information...
2 parents ab27e75 + 9bc6f61 commit 60589ecb9734ac9f63644829f1e0a5879af4710e @justinfrench committed Jan 3, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/formtastic/helpers/reflection.rb
View
5 lib/formtastic/helpers/reflection.rb
@@ -7,7 +7,10 @@ module Reflection
def reflection_for(method) #:nodoc:
if @object.class.respond_to?(:reflect_on_association)
@object.class.reflect_on_association(method)
- elsif @object.class.respond_to?(:associations) # MongoMapper uses the 'associations(method)' instead
+
+ # MongoMapper uses the 'associations(method)' instead
+ # ReactiveResource does as well but its an array. Also make sure we are working with a hash
+ elsif @object.class.respond_to?(:associations) && @object.class.is_a?(Hash)
@object.class.associations[method]
end
end

0 comments on commit 60589ec

Please sign in to comment.