# method location

**URL:** <https://discuss.rubyonrails.org/t/method-location/42531>\
**Category:** rubyonrails-talk\
**Created:** [May 14, 2009, 6:08pm UTC](https://discuss.rubyonrails.org/t/method-location/42531 "2009-05-14T18:08:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![p\_W](https://avatars.discourse-cdn.com/v4/letter/p/a6a055/32.png) [@p\_W](https://discuss.rubyonrails.org/u/p_W)\
**Post date:** [May 14, 2009, 6:08pm UTC](https://discuss.rubyonrails.org/t/method-location/42531/1 "2009-05-14T18:08:58Z")

</div>

I am a novice writing a simple address book app. It is just using the simple CRUD operations, but I would like to write a function for the index view that divides the records up by the first letter of the last name so I can have jump links at the top to take you to a specific group of records according to their last name. Should this function be put in the controller, or the model?

---

<div class="post-metadata">

**Author:** ![Colin\_Law1](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Colin\_Law1](https://discuss.rubyonrails.org/u/Colin_Law1)\
**Post date:** [May 14, 2009, 7:39pm UTC](https://discuss.rubyonrails.org/t/method-location/42531/2 "2009-05-14T19:39:55Z")

</div>

I think I would have a Model method that provides the records as an array of arrays, each element of the outer array being an array of records with the same first letter of the name. This would be asked for by the controller and passed to the view for display as appropriate. The view would put the links in using appropriate view helper methods.

Or perhaps the Model method would take a collection of records and convert it to the array of array form. Then one could do @records = Model.find(…).in\_groups or whatever the method is called
