From 7cd1b7a7a46d5974f144506295135a6e5340efc5 Mon Sep 17 00:00:00 2001 From: Louis Knapp Date: Sun, 24 Jul 2016 08:11:19 -0500 Subject: [PATCH] lk | renames columns on agencies table --- app/controllers/agencies_controller.rb | 6 +++--- app/views/agencies/_fields.html.haml | 16 ++++++++-------- app/views/agencies/_form.html.haml | 6 +++--- app/views/agencies/edit.html.haml | 4 ++-- app/views/agencies/index.html.haml | 4 ++-- ...change_agency_phone_number_to_agency_phone.rb | 6 ++++++ db/schema.rb | 6 +++--- 7 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 db/migrate/20160724130507_change_agency_phone_number_to_agency_phone.rb diff --git a/app/controllers/agencies_controller.rb b/app/controllers/agencies_controller.rb index 77f79f2..7e71ee7 100644 --- a/app/controllers/agencies_controller.rb +++ b/app/controllers/agencies_controller.rb @@ -45,13 +45,13 @@ class AgenciesController < ApplicationController def agency_params params.require(:agency).permit( - :agency_name, + :name, :contact_name, :street_address, :city, :state, :postal_code, - :phone_number, - :email) + :phone, + :email) end end diff --git a/app/views/agencies/_fields.html.haml b/app/views/agencies/_fields.html.haml index febdb19..a6b3eb4 100644 --- a/app/views/agencies/_fields.html.haml +++ b/app/views/agencies/_fields.html.haml @@ -1,12 +1,12 @@ -- disabled ||= false +- disabled ||= false .form-horizontal .form-group - = f.label "Name of Agency:", class: "col-sm-2 control-label" + = f.label "Name of Agency:", class: "col-sm-2 control-label" .col-sm-10 - = f.text_field :agency_name, class: "form-control", disabled: disabled + = f.text_field :name, class: "form-control", disabled: disabled .form-group - = f.label "Contact Name:", class: "col-sm-2 control-label" + = f.label "Contact Name:", class: "col-sm-2 control-label" .col-sm-10 = f.text_field :contact_name, class: "form-control", disabled: disabled @@ -14,7 +14,7 @@ = f.label "Street Address:", class: "col-sm-2 control-label" .col-sm-10 = f.text_field :street_address, class: "form-control", disabled: disabled - + .form-group = f.label "City:", class: "col-sm-2 control-label" .col-sm-10 @@ -24,16 +24,16 @@ = f.label "State:", class: "col-sm-2 control-label" .col-sm-10 = f.text_field :state, class: "form-control", disabled: disabled - + .form-group = f.label "Postal Code:", class: "col-sm-2 control-label" .col-sm-10 = f.text_field :postal_code, class: "form-control", disabled: disabled - + .form-group = f.label "Phone Number", class: "col-sm-2 control-label" .col-sm-10 - = f.text_field :phone_number, class: "form-control", disabled: disabled + = f.text_field :phone, class: "form-control", disabled: disabled .form-group = f.label "email", class: "col-sm-2 control-label" diff --git a/app/views/agencies/_form.html.haml b/app/views/agencies/_form.html.haml index 458ed49..fb7dfb5 100644 --- a/app/views/agencies/_form.html.haml +++ b/app/views/agencies/_form.html.haml @@ -1,11 +1,11 @@ = form_for @agency, html: {class: 'form-horizontal'} do |f| - - if @agency.errors.any? + - if @agency.errors.any? #error_explanation %h2= pluralize(@agency.errors.count, "error") + " prohibited this agency from being saved:" %ul - @agency.errors.full_messages.each do |msg| - %li= msg - = render 'fields', f: f + %li= msg + = render 'fields', f: f .row .actions.col-sm-offset-2 = f.submit class: "btn btn-default" diff --git a/app/views/agencies/edit.html.haml b/app/views/agencies/edit.html.haml index 281f2d6..80e70e8 100644 --- a/app/views/agencies/edit.html.haml +++ b/app/views/agencies/edit.html.haml @@ -1,6 +1,6 @@ .container - %h1 Edit Agency - = render 'form' + %h1 Edit Agency + = render 'form' = link_to 'Show', @agency | = link_to 'Back', agencies_path diff --git a/app/views/agencies/index.html.haml b/app/views/agencies/index.html.haml index 53a238d..6603b30 100644 --- a/app/views/agencies/index.html.haml +++ b/app/views/agencies/index.html.haml @@ -11,10 +11,10 @@ %tbody - @agencies.each do |agency| %tr - %td= agency.agency_name + %td= agency.name %td= link_to 'Show', agency %td= link_to 'Edit', edit_agency_path(agency) %td= link_to 'Destroy', agency, method: :delete, data: { confirm: 'Are you sure?' } - + %br = link_to ' + New Agency', new_agency_path, class: "btn btn-default" diff --git a/db/migrate/20160724130507_change_agency_phone_number_to_agency_phone.rb b/db/migrate/20160724130507_change_agency_phone_number_to_agency_phone.rb new file mode 100644 index 0000000..bf0a86a --- /dev/null +++ b/db/migrate/20160724130507_change_agency_phone_number_to_agency_phone.rb @@ -0,0 +1,6 @@ +class ChangeAgencyPhoneNumberToAgencyPhone < ActiveRecord::Migration + def change + rename_column :agencies, :phone_number, :phone + rename_column :agencies, :agency_name, :name + end +end diff --git a/db/schema.rb b/db/schema.rb index 41ad126..e6e9b5c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,19 +11,19 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160717165815) do +ActiveRecord::Schema.define(version: 20160724130507) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "agencies", force: :cascade do |t| - t.string "agency_name" + t.string "name" t.string "contact_name" t.string "street_address" t.string "city" t.string "state" t.string "postal_code" - t.string "phone_number" + t.string "phone" t.string "email" end