From 88934ca5a7cfa40330162a27ac48b200f636e97a Mon Sep 17 00:00:00 2001
From: Marcela Ribeiro de Oliveira <mro15@inf.ufpr.br>
Date: Wed, 26 Oct 2016 10:01:22 -0200
Subject: [PATCH 1/2] change columns complaintable_type and complaintable_id to
 complainable_type and complainable_id

---
 app/controllers/v1/complaints_controller.rb |  2 +-
 app/models/complaint.rb                     | 10 +++++-----
 app/models/concerns/complainable.rb         |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/app/controllers/v1/complaints_controller.rb b/app/controllers/v1/complaints_controller.rb
index e23fce51d..b7803f0a6 100644
--- a/app/controllers/v1/complaints_controller.rb
+++ b/app/controllers/v1/complaints_controller.rb
@@ -30,7 +30,7 @@ class V1::ComplaintsController < ApplicationController
   end
 
   def complaint_params
-    params.require(:complaint).permit(:user_id, :description,:complaintable_id, :complaint_reason_id, :complaintable_type)
+    params.require(:complaint).permit(:user_id, :description,:complainable_id, :complaint_reason_id, :complainable_type)
   end
 
 end
diff --git a/app/models/complaint.rb b/app/models/complaint.rb
index 9dc2333ec..e8bdae316 100644
--- a/app/models/complaint.rb
+++ b/app/models/complaint.rb
@@ -5,8 +5,8 @@
 #  id                  :integer          not null, primary key
 #  description         :text
 #  user_id             :integer
-#  complaintable_id    :integer
-#  complaintable_type  :string
+#  complainable_id    :integer
+#  complainable_type  :string
 #  complaint_reason_id :integer
 #  created_at          :datetime         not null
 #  updated_at          :datetime         not null
@@ -18,10 +18,10 @@ class Complaint < ApplicationRecord
 
   belongs_to :complaint_reason
   belongs_to :user
-  belongs_to :complaintable, polymorphic: true
+  belongs_to :complainable, polymorphic: true
 
-  validates_presence_of :user, :complaintable, :description, :complaint_reason
-  validates :user_id, uniqueness: { scope: [:complaintable_id, :complaintable_type] }
+  validates_presence_of :user, :complainable, :description, :complaint_reason
+  validates :user_id, uniqueness: { scope: [:complainable_id, :complainable_type] }
 
   acts_as_paranoid
   has_paper_trail
diff --git a/app/models/concerns/complainable.rb b/app/models/concerns/complainable.rb
index f3a596ef0..cc6e5cd10 100644
--- a/app/models/concerns/complainable.rb
+++ b/app/models/concerns/complainable.rb
@@ -2,7 +2,7 @@ module Complainable
   extend ActiveSupport::Concern
 
   included do
-      has_many :complaints, as: :complaintable
+      has_many :complaints, as: :complainable
   end
 
 end
-- 
GitLab


From 1dd462ffb75655d09d7aa5acaf830f905e4adcea Mon Sep 17 00:00:00 2001
From: Marcela Ribeiro de Oliveira <mro15@inf.ufpr.br>
Date: Wed, 26 Oct 2016 10:01:39 -0200
Subject: [PATCH 2/2] change columns complaintable_type and complaintable_id to
 complainable_type and complainable_id

---
 .../20161026114123_change_complaints_columns_names.rb       | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 db/migrate/20161026114123_change_complaints_columns_names.rb

diff --git a/db/migrate/20161026114123_change_complaints_columns_names.rb b/db/migrate/20161026114123_change_complaints_columns_names.rb
new file mode 100644
index 000000000..7371830fe
--- /dev/null
+++ b/db/migrate/20161026114123_change_complaints_columns_names.rb
@@ -0,0 +1,6 @@
+class ChangeComplaintsColumnsNames < ActiveRecord::Migration[5.0]
+  def change
+    rename_column :complaints, :complaintable_id, :complainable_id
+    rename_column :complaints, :complaintable_type, :complainable_type
+  end
+end
-- 
GitLab