You have three Select Boxes one for States, second for city and third for college.

What You want to Do :-

You want that if Some one selects State for Example :- Karnataka, the next drop down will automatically show u the lists of cities that comes Under Karnataka, Furthermore if you select Say Bangalore, the third drop down will show You the lists of colleges that comes under that city.

In short:-

STATE -> CITY -> COLLEGE

KARNATAKA -> BANGALORE -> IIT,Bangalore

Ruby on Rails with Ajax makes it very easy to achieve, It’s a 5 Step Process, Let’s See How

Note: this will create another controller named colleges_controller.rb in your app/controllers directory.

You have done with your 3rd Step. Now we will move onto our fourth step

Step4: Create a Third Model with name = User, where we will display all the action, for that type :

: ruby script/generate model User

This will create some files into your application, now open your Fourth migration file in your editor

i.e fever/db/migrate/004_create_users.rb

Type

: t.column :firstname, :string

t.column :lastname, :integer

save it(I think two fields are more than enough to solve my purpose here).

Create a scaffold of this model

: ruby script/generate scaffold User

Note: that’s it. You have done with your basics steps, now we will use Ajax here, but before that I want you to insert some values of states, cities and colleges manually, be sure that you are giving right ‘state_id’, and ‘city_id’ in your corresponding ‘cities’ and ‘colleges’ tables

Step 5: Open app/views/users/new.rhtml

and type below line between your head section

: <HEAD>

<%= javascript_include_tag “prototype” %>

</HEAD>

Open app/views/users/_form.rhtml, and type the below code after your firstname and lastname fields