Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix mongo_mapper related issue: mongo_mapper doesn't respond to refle…

…ct_on_association(), but associations() instead
  • Loading branch information...
commit a452caf3faff9c51da949137dece92f0462a1c5e 1 parent 14aef5f
@ijonas ijonas authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/formtastic/helpers/inputs_helper.rb
View
14 lib/formtastic/helpers/inputs_helper.rb
@@ -314,9 +314,17 @@ def default_columns_for_object
end
def fieldset_contents_from_column_list(columns)
- columns.collect do |method|
- if @object && (@object.class.reflect_on_association(method.to_sym) && @object.class.reflect_on_association(method.to_sym).options[:polymorphic] == true)
- raise PolymorphicInputWithoutCollectionError.new("Please provide a collection for :#{method} input (you'll need to use block form syntax). Inputs for polymorphic associations can only be used when an explicit :collection is provided.")
+ columns.collect do |method|
+ if @object
+ if @object.class.respond_to?(:reflect_on_association)
+ if (@object.class.reflect_on_association(method.to_sym) && @object.class.reflect_on_association(method.to_sym).options[:polymorphic] == true)
+ raise PolymorphicInputWithoutCollectionError.new("Please provide a collection for :#{method} input (you'll need to use block form syntax). Inputs for polymorphic associations can only be used when an explicit :collection is provided.")
+ end
+ elsif @object.class.respond_to?(:associations)
+ if (@object.class.associations(method.to_sym) && @object.class.associations(method.to_sym).options[:polymorphic] == true)
+ raise PolymorphicInputWithoutCollectionError.new("Please provide a collection for :#{method} input (you'll need to use block form syntax). Inputs for polymorphic associations can only be used when an explicit :collection is provided.")
+ end
+ end
end
input(method.to_sym)
end
Please sign in to comment.
Something went wrong with that request. Please try again.