This is for a glossary that I setup ...

class Glossary
  def self.find_glossaries(options = {})
    if options[:category].blank?
      paginate :per_page => options[:per_page], :page => options
[:page],
        :conditions => ["term LIKE ?", options[:letter]+"%"], :order
=> "term"
    else
    end
  end
end

Then in the controller
@letter = params[:letter].blank? ?
@category.glossaries.collect.first.term.first.upcase : params[:letter]
 @glossaries = @category.glossaries.find_glossaries(:letter =>
@letter, :page => params[:page])


There is more to this but the the important one is the model
find_glossaries


And then this view helper:

  def letter_options(category=nil)
    if category.nil?
      @letter_options_list = Glossary.all.collect!{|c|
c.term.first.upcase }.uniq.sort!
    else
      @letter_options_list = category.glossaries.collect!{|c|
c.term.first.upcase }.uniq.sort!
    end
  end

I hope this get you going...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to