I have ran into a stumbling block sorting a group_by
In my model, I have defined a method called "due_by_in_words", this method returns a hash with a :key and a :value based on a number of elsif statements.
{:key => 1, :value => 'Overdue'} {:key => 2, :value => 'Today'} etc...
In my controller I have:
@tickets_due_by = @tickets.group_by { |t| t.due_by_in_words[:key] }
Which is grouping based on the hashes :key, this is working very well.
What I want to do now, is to display the :value from the hash, in my view I have:
<% @tickets_due_by.sort.each do |due_by_in_words, tickets| %> <h2><%= due_by_in_words %></h2> <% for ticket in tickets %> HTML here... <% end %> <% end %>
This is, of course, only displaying the :key (1,2,3...), I would like to be able to access the :value of the hash, but it won't be accessible to the view, at least I don't think it will be. It seems to me that the "due_by_in_words" will only contain the :key of the hash, and not the entire hash.
I want to be able to display the :value as a header of sorts
Any thoughts?