Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/rails_admin/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,13 @@ def reload!
def visible_models(bindings)
visible_models_with_bindings(bindings).sort do |a, b|
if (weight_order = a.weight <=> b.weight) == 0
a.label.casecmp(b.label)
result = a.label.casecmp(b.label)
if result.zero? && a.try(:model) && b.try(:model)
# If two models have the same label, fallback to the model name
# for a deterministic ordering.
result = a.model.name.casecmp(b.model.name)
end
result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having something like this can be simpler?

      def visible_models(bindings)
        visible_models_with_bindings(bindings).sort_by do |model|
          [model.weight, model.label.downcase, model.model.name.downcase]
        end
      end

else
weight_order
end
Expand Down
Loading