开发者

Grouping by Name but disregarding capitalization

开发者 https://www.devze.com 2023-02-01 10:00 出处:网络
I have b开发者_StackOverflow中文版uilt a Ruby on Rails app that allows users to track workouts. I also allow them to add groups (like blog tags) to workouts to help keep organized. In most places wher

I have b开发者_StackOverflow中文版uilt a Ruby on Rails app that allows users to track workouts. I also allow them to add groups (like blog tags) to workouts to help keep organized. In most places where I display the tags I do so by grouping by name.

@group_counts = current_user.groups.count(:group => :name, 
       :order => 'count_all DESC')

Is there a way to disregard capitalization. For instance I have two different records returned for Push press and Push Press.


You may want to consider putting a callback in your Group model to downcase or upcase the user input to make everything consistent. That way you don't have to deal with the capitalization issue in the query.

0

精彩评论

暂无评论...
验证码 换一张
取 消