TrestleAdmin / trestle

A modern, responsive admin framework for Ruby on Rails
https://trestle.io
GNU Lesser General Public License v3.0
1.94k stars 173 forks source link

Ensure menu items with sym/str names can be sorted #431

Closed johansenja closed 1 year ago

johansenja commented 1 year ago

Hello - I recently updated a few gems locally in one of my apps (including Trestle 0.9.5 to 0.9.7), and for some reason this broke Trestle pages in the app, with a fairly cryptic error:

Screenshot 2022-12-16 at 15 21 48 Screenshot 2022-12-16 at 15 21 52

After a lot of digging, I realised it was because some of our menu items had their names defined as symbols (eg :blog_posts), and some as strings ("Longer name written as string"), so because Menu::Item#<=> looks at the name, and because :symbol <=> "string" returns nil, this was breaking the sorting (but coming from quite a deep place).

It's quite a simple fix, but happy to share a bit more context if it's helpful!

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

spohlenz commented 1 year ago

Thank you for the fix!