Skip to content

Instantly share code, notes, and snippets.

@speedmax
Created January 2, 2009 07:09
Show Gist options
  • Save speedmax/42486 to your computer and use it in GitHub Desktop.
Save speedmax/42486 to your computer and use it in GitHub Desktop.
def index
@az_idols = ("a"..."z").reduce({}) do |result, letter|
res = Idol.find :all, :conditions=>["name LIKE ?", "#{letter}%"]
result[letter] = res unless res.empty?
result
end.sort
end
<% @az_idols.each do |letter, idols| %>
<h2>AV idol start with <%= letter %></h2>
<!-- Here will be your old for loop.. just rename @idols to idols and everything will work again -->
<% for idol in idols %>
<%= idol.name %>
<%= link_to :edit, idol_edit_path(idol) %>
...
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment