diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 08cb35e..e414a16 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -11,7 +11,7 @@ def show def json_attributes { - only: [:doc_number, :doc_type], + only: [:doc_number, :doc_type, :email, :nickname], methods: [:full_name], include: { tasks: { diff --git a/app/models/person.rb b/app/models/person.rb index fb684ea..211e91f 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,6 +1,8 @@ class Person < ApplicationRecord has_many :tasks + self.ignored_columns = [:email] + def full_name "#{last_name}, #{first_name}" end diff --git a/db/migrate/20230111142035_add_email_to_person.rb b/db/migrate/20230111142035_add_email_to_person.rb new file mode 100644 index 0000000..b7f8327 --- /dev/null +++ b/db/migrate/20230111142035_add_email_to_person.rb @@ -0,0 +1,5 @@ +class AddEmailToPerson < ActiveRecord::Migration[6.1] + def change + add_column :people, :email, :string + end +end diff --git a/db/migrate/20230111153146_add_nickname_to_people.rb b/db/migrate/20230111153146_add_nickname_to_people.rb new file mode 100644 index 0000000..a0aaabd --- /dev/null +++ b/db/migrate/20230111153146_add_nickname_to_people.rb @@ -0,0 +1,6 @@ +# Migration for adding the nickname column to People +class AddNicknameToPeople < ActiveRecord::Migration[6.1] + def change + add_column :people, :nickname, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index fa3907b..ff35c56 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_01_11_061901) do +ActiveRecord::Schema.define(version: 2023_01_11_153146) do create_table "people", force: :cascade do |t| t.string "first_name" @@ -19,6 +19,8 @@ t.string "doc_type" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "email" + t.string "nickname" end create_table "tasks", force: :cascade do |t|