You are here

model

Ruby on Rails Model Auto Completer

When developing web applications nowadays, caring about user interaction is mandatory. Using Ajax technology to allow your system to show information without reloading the whole page is one of the features every web user is getting used to.

 

One good example on this kind of interaction are those text boxes with auto completion. While the user types some name the system will automatically search for matches to those names in the database, offering sugestions on possible existing values.

 

Ruby on Rails Order By Using Associated Model

It is very easy to use an 'order by' clause in a model in Ruby on Rails. Supposing you have a Category model it's as simple as doing this:
 
@categories = Category.find(:all, :order => 'title')
 
But what if I need to order by the title of the subcategories after ordering by the categories title?
 
Using the category_id does not work either, because it almost sure that the categories will not be added in alphabetical order, so the command below does not work for me either:
 

Subscribe to RSS - model