Dynamic Select Menus

I watched the railscast episode 88: http://railscasts.com/episodes/88-dynamic-select-menus?autoplay=true

Only problem is that it uses a State and Country model that are not shown. Can anyone help me with this? I mean, how am I supposed to do this, should

i manually populate the database at the console?

Also, is there a way to do this without saving states and countries to the database (just to save some space)?

And further more, is there a way to do this without javascript? (for example, with observer_field like in http://www.plexusweb.com/staff/charlie/blog/post/302/Dynamic-Select-Menus-in-Rails-using-ObserveField ? problem is I think observer_field no longer exists for rails 3).

Thank you,


Hey Rodrigo,

Have you looked inside db/seeds.rb? That file demonstrates seeding a City model. Other things you can do, depending on what you need the data to look like are simple things like:

states = %w[Alabama Alaska Arkansas]

I also think Ryan did a railscast on models that don’t exist in the database, in case you need more model-like behavior than an array of strings would give you.

Good luck!