alphabetical view of posts.

You would sort them in the controller. Your controller may look like:

class PostsController < ApplicationController   def index     @posts = Post.find(:all)     ...   end ... end

Change the find to be:

    @posts = Post.find(:all, :order => "last_name, first_name")

So, @posts, when it gets to the view, is ordered the way you want it. The view simply does the viewing.

raj wrote:

I have a small problem here....

like when they click on A i am calling showa function in controller, where I get all the post whose title starts with A. This I am doing for all the alphabets. But I am trying to use only one view and redirecting to list...but it says @posts is undefined in the view.

On solution is to have one view page for each alphabet but i need to have 24 pages which is a wrong design. How do I handle this.

Thank you.    Don't call showa. call show and pass the letter as a param.

def show   @posts = Post.find( :all, :conditions => [ "title LIKE '?%'", params[ :starts_with ] ] )   render :action => 'list'; end

right...

change to:

title LIKE ?

and

append the % on the end of the params[ :starts_with ]

Ravindraraj Mamadgi wrote: