Created
January 2, 2009 07:09
-
-
Save speedmax/42486 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @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