levitra sans ordonnance viagra deutschland kaufen comprar cialis barato viagra generique pas cher cialis pris finasteride online cialis en españa viagra market levitra prezzo farmacia libera vendita viagra viagra kaufen preisvergleich comprare viagra a roma viagra original ohne rezept viagra 1 euro viagra francais
vardenafil generique viagra se compra con receta kamagra apoteket levitra online cialis medicinale viagra maksaa priligy generika kamagra se vende en farmacias viagra preise deutschland vente viagra inde cialis online rezept viagra på nettet baclofen 5 mg cialis in contrassegno acheter cialis discrètement

Seeding Rails App With RESTful Address Data

Grabbing data from Restful webservices has never been easier. I use this code in the Rails /db/seeds.rb file to grab data from the Danish webservice with addresses, municipalities, regions, etc.

I decided to import the data into a local database to ensure it could work offline.

Code from



Now I can access municipalities in a grouped selectbox like so in the view code:

<% options = option_groups_from_collection_for_select(Region.all, :kommuner, :name, :id, :name) %> <%= f.select("kommune_id", options, {}, {:class => "short"}) %>

The final result rendered in the user interface:

This code is based on Rails 2.3.5.

One Response to “Seeding Rails App With RESTful Address Data”

  1. Neeraj Dhiman Says:

    Great stuff and thanks for doing all of this.

    Quick question…given that I’m already using Factories for my testing, what is the advantage of using seed_fu over a custom rake task using Factories? It seems like I’d be just re-creating my Factory code.

    Note that my comments relate to creating data for development and testing purposes – not seeding a database with static data (e.g. AK, AZ….).

    thanks again, great stuff