How to use my model with conditions

You cant to add a model and a controller for each letter fo the alphabet? That's definately not DRY at all.... You should manage every letter in the same controller, and with the same model: - ClientController - Client (Model) #Controller: class ClientController < ActionController::Base

  def index      if params[:letter]       cond = params[:letter] + "%"       @letter = params[:letter]       @clients = Client.find :all, :conditions => ["name like ?", cond], :order => "clients.name ASC"     else       @client = Clients.find :all, :order => "clients.name ASC"     end   end end

#Model: class client ActiveRecord::Base ...model logic... none nessessary for your example... end

#view: index.rhtml <html>   <head>     <%if @letter %>        <title>Listing Clients with First Name starting with <%= @letter %></title>     <% else %>        <title>Listing all Clients</title>     <% end %>   </head>   <body>     <h1>Names By :</h1>     <table>     <% @clients.each do |client| %>       <tr>         <td><%= link_to client.firstname, :action => 'show', :id => client.id %></td>       </tr>     <%end%>     </table>      <%= link_to "All Names with N", {:action => index, :letter => "N" } -%>      <%= link_to "All Names with O", {:action => index, :letter => "O" } -%>      ....      ....   </body> </html>

Of Course i would use a dropdown to select the letter instead of link_to's, and do the layout differently, but for an example it should suffice.

Well probably something with the find method/conditions it wrong. seems it doesn't return any rows. You should check the devlopment.log to see what SWL was generated, us script/console to do the find manually and see what it returns... Is there really a column "firstname" in you "clients" table?

oh... i just see that you left out the "else" statement in the controller, which finds all clients names if no :letter is passed in the params. either you put that back in (and in the view as well) or you create some other kind of else method, like redirecting to another page if no letter is given.