File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
app/controllers/forest_liana Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -156,10 +156,12 @@ def fields_per_model(params_fields, model)
156156 params_fields_hash . inject ( { } ) do |fields , param_field |
157157 relation_name = param_field [ 0 ]
158158 relation_fields = param_field [ 1 ]
159+ forest_collection = ForestLiana . apimap . find { |collection | collection . name . to_s == model . to_s . gsub ( '::' , '__' ) }
160+ smart_relations = forest_collection . fields_smart_belongs_to
159161
160162 if relation_name == ForestLiana . name_for ( model )
161163 fields [ relation_name ] = relation_fields
162- else
164+ elsif model . reflect_on_association ( relation_name . to_sym )
163165 model_association = model . reflect_on_association ( relation_name . to_sym )
164166 if model_association
165167 model_name = ForestLiana . name_for ( model_association . klass )
@@ -173,7 +175,14 @@ def fields_per_model(params_fields, model)
173175 fields [ model_name ] = relation_fields
174176 end
175177 end
178+ else
179+ smart_relations . each do |smart_relation |
180+ if smart_relation [ :field ] . to_s == relation_name
181+ fields [ smart_relation [ :reference ] . split ( '.' ) . first ] = relation_fields
182+ end
183+ end
176184 end
185+
177186 fields
178187 end
179188 else
You can’t perform that action at this time.
0 commit comments