topsavingspharmacy compra levitra genericos acquisto viagra con mastercard cialis sans ordonnance en belgique viagra senza ricetta medica in italia on line viagra precio mastercard comprare viagra in italia online prijs cialis achat bviagra ben bligne viagra grande bretagne venta de cialis cialis generico funziona generisk viagra viagra discret levitra achat
kamagra sousajours 
pharmacie en ligne paris 
achat viagra en ligne pas cher 
vente viagra andorre 
levitra ordonnance 
levitra mg 
kamagra en france 
achat cialys 
commander du viagra en ligne 
viagra moin cher 
acheter viagra professionnelle en france 
viagra en vente libre 
levitra livraison express 
prix boite cialis 
trouver du levitra 
tarif priligy how much is propecia discount viagra online cialis no prescription kamagra without prescription low cost cialis finasteride cipla order propecia online no prescription order viagra kamagra sale viagra low cost online finasteride for sale buy cialis visa cialis best prices buy cialis

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

/db/seeds.rb

file:

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