Skip to content

Instantly share code, notes, and snippets.

@amysimmons
Last active December 26, 2017 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amysimmons/7df7898d29c1c1e145ff to your computer and use it in GitHub Desktop.
Save amysimmons/7df7898d29c1c1e145ff to your computer and use it in GitHub Desktop.
WDI Week 5 Notes

#WDI Week 5 Notes

##Monday

###Bootstrap

##Tuesday

###Deployment

add to gemfile

gem 'rails_12factor', :group => :production

bundle

heroku run rake db:migrate

heroku run rake db:seed

git push heroku master

heroku pg:info shows the database

###Geocoding

require this gem in your rails app

gem 'geocoder'

bundle

in the rails console

Geocoder.search "56 York Street Sydney"

address = Geocoder.search "56 York Street Sydney"

address.first.latitude

address.first.longitude

if we paste those coordinates into google it will return a map

in places folder,

rails generate scaffold location name:text address:text latitude:float longitude:float

add this to the class

class Location < ActiveRecord::Base geocoded_by :address after_validation :geocode end

now whenever we enter an address, it wil give us the lat and long

whats my ip address

Geocoder.search '202.171.181.44' will return location based on the ip address

https://developers.google.com/maps/documentation/embed/start

register

google api console

turn on Google Maps Embed API

api access

take api key

paste the api key to generate the map

substituted the following in the iframe to make it dynamic

<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/view?zoom=16&center=<%=@location.latitude%>%2C<%=@location.longitude%>&key=AIzaSyBTqWAvl9DDiewoanjO5KVKCzwMmzh3Xmo"></iframe>

<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/view?zoom=16&center=-33.8679%2C151.2059&key=AIzaSyBTqWAvl9DDiewoanjO5KVKCzwMmzh3Xmo"></iframe>

Geocoder screencast:

http://railscasts.com/episodes/273-geocoder

##Wednesday

###Image uploads

##Thursday

##Friday

###Project 1 presentations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment