diff --git a/Gemfile b/Gemfile index 6a3a07c..5ddbae0 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,7 @@ gem 'pyr', '~> 0.4.0' gem 'rack-flash3', '~> 1.0.0', '>= 1.0.5' gem 'rake', '~> 12.0.0' gem 'require_all', '~> 1.4.0' +gem 'safe_yaml' gem 'sinatra', '~> 2.0.2' gem 'sinatra-activerecord', '~> 2.0.0', diff --git a/Gemfile.lock b/Gemfile.lock index 2aec837..dd33be1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,6 +116,7 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) + safe_yaml (1.0.4) scoped_attr_accessor (1.0.3) shotgun (0.9.2) rack (>= 1.0) @@ -174,6 +175,7 @@ DEPENDENCIES require_all (~> 1.4.0) rspec (~> 3.6.0) rubocop (~> 0.48.0, >= 0.48.1) + safe_yaml shotgun (~> 0.9.0, >= 0.9.2) simplecov (~> 0.14.0) sinatra (~> 2.0.2) diff --git a/app/models/concerns/api_findable.rb b/app/models/concerns/api_findable.rb index 01c7841..d00d0a0 100644 --- a/app/models/concerns/api_findable.rb +++ b/app/models/concerns/api_findable.rb @@ -41,8 +41,8 @@ def parse_vcard_url(rep) if capitol_office capitol_office.v_card_link else - district_office = rep.office_locations.where(office_type: 'district').first - district_office.v_card_link if district_office + dist_office = rep.office_locations.where(office_type: 'district').first + dist_office&.v_card_link end end diff --git a/db/schema.rb b/db/schema.rb index bd0d594..65d946e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -10,65 +12,63 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170328221922) do - - create_table "calls", force: :cascade do |t| - t.string "bioguide_id" - t.string "comments" - t.boolean "got_through", default: false - t.boolean "busy", default: false - t.boolean "voice_mail", default: false - t.boolean "mailbox_full", default: false - t.integer "rating" - t.integer "user_id" - t.integer "office_location_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false +ActiveRecord::Schema.define(version: 20_170_328_221_922) do + create_table 'calls', force: :cascade do |t| + t.string 'bioguide_id' + t.string 'comments' + t.boolean 'got_through', default: false + t.boolean 'busy', default: false + t.boolean 'voice_mail', default: false + t.boolean 'mailbox_full', default: false + t.integer 'rating' + t.integer 'user_id' + t.integer 'office_location_id' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false end - create_table "office_locations", force: :cascade do |t| - t.string "bioguide_id" - t.string "locality" - t.string "region" - t.string "postal_code" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "phone" - t.string "office_type" - t.boolean "active", default: true - t.string "office_id" + create_table 'office_locations', force: :cascade do |t| + t.string 'bioguide_id' + t.string 'locality' + t.string 'region' + t.string 'postal_code' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.string 'phone' + t.string 'office_type' + t.boolean 'active', default: true + t.string 'office_id' end - create_table "reps", force: :cascade do |t| - t.string "bioguide_id" - t.string "official_full" - t.string "family_name" - t.string "given_name" - t.string "additional_name" - t.string "honorific_prefix" - t.string "honorific_suffix" - t.string "party_identification" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "state" - t.string "vcard" - t.string "photo" - t.string "district" - t.string "url" - t.string "twitter" - t.string "youtube" - t.string "facebook" - t.string "instagram" - t.boolean "active", default: true + create_table 'reps', force: :cascade do |t| + t.string 'bioguide_id' + t.string 'official_full' + t.string 'family_name' + t.string 'given_name' + t.string 'additional_name' + t.string 'honorific_prefix' + t.string 'honorific_suffix' + t.string 'party_identification' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.string 'state' + t.string 'vcard' + t.string 'photo' + t.string 'district' + t.string 'url' + t.string 'twitter' + t.string 'youtube' + t.string 'facebook' + t.string 'instagram' + t.boolean 'active', default: true end - create_table "users", force: :cascade do |t| - t.string "username" - t.string "email" - t.string "password_digest" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "slug" + create_table 'users', force: :cascade do |t| + t.string 'username' + t.string 'email' + t.string 'password_digest' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.string 'slug' end - end diff --git a/db/test.sqlite b/db/test.sqlite index cb43849..8ee61f9 100644 Binary files a/db/test.sqlite and b/db/test.sqlite differ