@@ -118,11 +118,6 @@ def relationship_related_link(attribute_name)
118118
119119 if ret [ :href ] . blank?
120120 begin
121- # if @options[:include].try(:include?, attribute_name.to_s) &&
122- # !SchemaHelper.is_smart_field?(object.class, attribute_name.to_s)
123- # object.send(attribute_name)
124- # end
125-
126121 SchemaUtils . many_associations ( object . class ) . each do |a |
127122 if a . name == attribute_name
128123 ret [ :href ] = "/forest/#{ ForestLiana . name_for ( object . class ) } /#{ object . id } /relationships/#{ attribute_name } "
@@ -140,14 +135,19 @@ def has_one_relationships
140135 return { } if self . class . to_one_associations . nil?
141136 data = { }
142137 self . class . to_one_associations . each do |attribute_name , attr_data |
143- next if !should_include_attr? ( attribute_name , attr_data )
144138 relation = object . class . reflect_on_all_associations . find { |a | a . name == attribute_name }
145- relation_class_name = ForestLiana . name_for ( relation . klass ) . demodulize
146- if object . send ( relation . foreign_key . to_sym ) &&
147- @options [ :fields ] [ relation_class_name ] . size == 1 &&
148- @options [ :fields ] [ relation_class_name ] . include? ( relation . klass . primary_key . to_sym )
149139
150- attr_data [ :attr_or_block ] = proc { relation . klass . new ( relation . klass . primary_key => object . send ( relation . foreign_key . to_sym ) ) }
140+ next if !should_include_attr? ( attribute_name , attr_data )
141+
142+ unless relation . polymorphic?
143+ relation_class_name = ForestLiana . name_for ( relation . klass ) . demodulize
144+
145+ if object . send ( relation . foreign_key . to_sym ) &&
146+ @options [ :fields ] [ relation_class_name ] &.size == 1 &&
147+ @options [ :fields ] [ relation_class_name ] &.include? ( relation . klass . primary_key . to_sym )
148+
149+ attr_data [ :attr_or_block ] = proc { relation . klass . new ( relation . klass . primary_key => object . send ( relation . foreign_key . to_sym ) ) }
150+ end
151151 end
152152
153153 data [ attribute_name ] = attr_data
0 commit comments