app/controllers/collections_controller.rb in iqvoc-3.2.11 vs app/controllers/collections_controller.rb in iqvoc-3.3.0
- old
+ new
@@ -27,11 +27,11 @@
tops.
sort { |a, b| a.pref_label.to_s <=> b.pref_label.to_s }
# When in single query mode, AR handles ALL includes to be loaded by that
# one query. We don't want that! So let's do it manually :-)
- Iqvoc::Collection.base_class.send(:preload_associations, @collections, [:subcollections])
+ ActiveRecord::Associations::Preloader.new(@collections, [:subcollections]).run
end
format.json do # For the widget
@collections = Iqvoc::Collection.base_class.with_pref_labels.merge(Label::Base.by_query_value("#{params[:query]}%"))
response = []
@collections.each { |c| response << collection_widget_data(c) }
@@ -46,11 +46,14 @@
authorize! :read, @collection
# When in single query mode, AR handles ALL includes to be loaded by that
# one query. We don't want that! So let's do it manually :-)
- Iqvoc::Collection.base_class.send(:preload_associations, @collection, [:pref_labels, {:subcollections => [:pref_labels, :subcollections]}, {:concepts => [:pref_labels] + Iqvoc::Concept.base_class.default_includes}])
+ ActiveRecord::Associations::Preloader.new(@collection,
+ [:pref_labels,
+ {:subcollections => [:pref_labels, :subcollections]},
+ {:concepts => [:pref_labels] + Iqvoc::Concept.base_class.default_includes}]).run
end
def new
authorize! :create, Iqvoc::Collection.base_class
@@ -78,11 +81,14 @@
authorize! :update, @collection
# When in single query mode, AR handles ALL includes to be loaded by that
# one query. We don't want that! So let's do it manually :-)
- Iqvoc::Collection.base_class.send(:preload_associations, @collection, [:pref_labels, {:subcollections => :pref_labels}, {:concepts => [:pref_labels] + Iqvoc::Concept.base_class.default_includes}])
-
+ ActiveRecord::Associations::Preloader.new(@collection, [
+ :pref_labels,
+ {:subcollections => :pref_labels},
+ {:concepts => [:pref_labels] + Iqvoc::Concept.base_class.default_includes}]).run
+
build_note_relations
end
def update
@collection = Iqvoc::Collection.base_class.by_origin(params[:id]).last