If you do not need a white listing:
@ideas_grouped = if (group = params[:group]).present? @ideas.group_by(&group.to_sym) end
If you need a whitelist, can you call include? first include? (see Amar's answer), but to add something new, let me push it using a declarative approach ( Object#whitelist remains as an exercise for the reader, maybe comes from Ick ):
@ideas_grouped = params[:group].whitelist(IdeaGroupers).maybe do |group| @ideas.group_by(&group.to_sym) end
source share