achat de viagra par internet 
viagra achat a l'unite 
génériques médicament cialis 
acheter viagra 
viagra commande jours 
cialis combien ca coute 
cialis prix pharmacie 
acheter générique cialis 
acheter du kamagra envoi rapide 
levitra 
acheter du levitra en ligne 
commander du viagra sur internet 
acheter viagra et cialis en ligne 
achat de viagra professional 
viagra allemagne 
achat viagra generique pas cher dk-viagra viagra luxembourg achat viagra générique sildénafil citrate tadalafil para mujeres offerta cialis viagra pas cher en pharmacie kopen viagra levitra mg on line in euro acheter du cialis le moins cher cialis 5mg generika receta viagra casera cialis 10 mg funziona viagra en ligne paypal cialis generico venta espana

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