The Ruby on Rails code is ready to downloaded. Here’s how to get it up and running in your environment:
- Download the zip file, gmaps_rails_code.zip
- Create your own empty Rails application (rails your_app_name)
- Unzip gmaps_rails_code.zip in the root of your newly created application. When you unzip the file, you will see it contains five root directories: app, db, lib, public, standalone_scripts. You want these directories to overlay the directories of your own Rails application.
- set up your config/database.yml as appropriate for your environment. Most people just use root/no password for their development environment.
- in routes.rb, add a line to configure the home_url:
map.home '', :controller => 'app', :action=>'index'
rake db:migrateto load the schema.
- In your config/environments/development.rb, add a line to specify your own Google Maps API key:
- Start your rails server, and go to http://localhost:3000/app (or adjust if your server is on a different port). You should see a welcome page and links to all the chapter examples.
These steps will give you the code and an empty database. This is meant to set the stage for you work with the various examples in the book. You will need to run the various data imports (capitol city scaping, FCC structure import, TIGER/Line data processing, etc) per the instructions in the book to fully populate the database.
After following the steps here, the examples in chapters 2,3,9, and 10 should work immediately. The rest of the chapters require some amount of data (primarily the FCC towers data), so you will need to load that data for the examples to work.
The Google Maps key is the primary configuration setting you need to get started. There are some others you will need for later chapters, however. You can add these to config/environments/development.rb file as well:
UK_POSTCODE_DIR="/path/to/your/uk/postcode/data" #the directory, not the file
Finally, note that the Ruby on Rails examples are live at http://book.earthcode.com.