Wednesday, August 21, 2013

Rails - How to create alphabetical system?

Rails - How to create alphabetical system?

I am getting data from my mySQL database with Ruby on Rails like that:
def all_specs
Specialization.order("title ASC").all;
end
Now, I would like to sort this data in the view file like that:
<div class="nav-column">
<h3>A</h3>
<ul class="submenu">
<li><a href="#">All data that has title that starts with A</a></li>
</ul>
</div>
<div class="nav-column">
<h3>A</h3>
<ul class="submenu">
<li><a href="#">All data that has title that starts with B</a></li>
</ul>
</div>
and so on from A-Z
How can I achieve that ?

No comments:

Post a Comment