app/controllers/spree/admin/orders_controller.rb in spree_backend-2.0.7 vs app/controllers/spree/admin/orders_controller.rb in spree_backend-2.0.8

- old
+ new

@@ -8,11 +8,11 @@ respond_to :html def index params[:q] ||= {} params[:q][:completed_at_not_null] ||= '1' if Spree::Config[:show_only_complete_orders_by_default] - @show_only_completed = params[:q][:completed_at_not_null].present? + @show_only_completed = params[:q][:completed_at_not_null] == '1' params[:q][:s] ||= @show_only_completed ? 'completed_at desc' : 'created_at desc' # As date params are deleted if @show_only_completed, store # the original date so we can restore them into the params # after the search @@ -33,11 +33,11 @@ params[:q][:completed_at_gt] = params[:q].delete(:created_at_gt) params[:q][:completed_at_lt] = params[:q].delete(:created_at_lt) end @search = Order.accessible_by(current_ability, :index).ransack(params[:q]) - @orders = @search.result.includes([:user, :shipments, :payments]). + @orders = @search.result(distinct: true).includes([:user, :shipments, :payments]). page(params[:page]). per(params[:per_page] || Spree::Config[:orders_per_page]) # Restore dates params[:q][:created_at_gt] = created_at_gt @@ -116,12 +116,11 @@ respond_with(@order) { |format| format.html { redirect_to :back } } end private - def load_order - @order = Order.find_by_number!(params[:id], :include => :adjustments) if params[:id] + @order = Order.includes(:adjustments).find_by_number!(params[:id]) authorize! action, @order end # Used for extensions which need to provide their own custom event links on the order details view. def initialize_order_events