rails sort_by and group_by


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. @posts.sort_by(&:date).each do |post|
  2. puts post
  3. end
  4.  
  5. @tasks = {}
  6. TaskList.find(:all).group_by(&:type) do |type, subtasks|
  7. @tasks[type] = subtasks.group_by(&:name)
  8. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.