Skip to content

Commit

Permalink
Force address to be unique (Fixes #399)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcmal authored and DeeDeeG committed Nov 14, 2018
1 parent b51fe20 commit f91d0b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/restroom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ class Restroom < ApplicationRecord
ignoring: :accents

validates :name, :street, :city, :state, presence: true
validates :street, uniqueness: {scope: [:city, :state], message: "is already registered"}

geocoded_by :full_address
after_validation :perform_geocoding, :reverse_geocode
before_validation :perform_geocoding, :reverse_geocode

reverse_geocoded_by :latitude, :longitude do |obj, results|
if geo = results.first
Expand Down

0 comments on commit f91d0b5

Please sign in to comment.