In the first part of this written just over a year ago I started the piece talking about revising designs. I wanted to fess up to the amount of things that are so awesome about this stack and just invite people to discuss their approaches as well.
A lot of this is coming from daily work in the stack, paying attention to the chatter about it on Github and other places, and it felt like it was time to lay things out. There’s no particular flow, just a collection of concepts or notes.
This is so common I’m amazed that it isn’t right in the docs.
Let’s say you wanted Users to belong to a company, but then your customer tells you, “Oh yeah we have these people who work at more than one location.”
The models have some Ruby code like this:
class User < ApplicationRecord
class Company < ApplicationRecord
It turns out to be very straight forward to refactor.
Generate a migration with the goals of creating a new join table for companies and users, migrate the existing
company_id data from the
Users table, and then update the Rails model accordingly. …
Geocoding is the process of taking latitude and longitude to determine an address, or taking an address and producing latitude and longitude coordinates.
There are numerous reasons an application needs to use a geocoder. For Now Serving, we use it during the sign up process, as well as making it easy to find nearby restaurants with a single click of ‘Find Me’.
Let’s get to coding!
We’ll need to grab the
mapbox-sdk and add it to the Gemfile.
gem 'mapbox-sdk', '~>2'
Create a simple initializer to set the access token in your app (e.g
Mapbox.access_token = MAPBOX_ACCESS_TOKEN
Next, let’s add a couple…