[Rails] Re: Alphabetically sorted list pages + dynamic forms

Stephen Bartholomew
Sun, 21 May 2006 09:05:43 -0000

That code would go in your controller in the action that carries out the
list:

def list
   @albums = Album.find(:all, :conditions => ["artist LIKE
''?%'' ",
params[:letter]])
end

Steve

Matt Andrews wrote:
> Stephen Bartholomew wrote:
>
>>This depends on which fields you want filtered and what your db layout
>>is, but basically you would need to find albums with the specified
>>letter at the beginning of the artist name:
>>
>>Album.find(:all, :conditions => ["artist LIKE
''?%'' ", params[:letter]])
>
>
> Thanks - whereabouts would this code go, though?
>
> Thanks for the other advice, I''ll give that a try.
>