Renamed job associations for operator and costumer
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
class Job < ApplicationRecord
|
||||
attr_accessor :current_user
|
||||
|
||||
belongs_to :costumer, class_name: "User", optional: true, counter_cache: :jobs_as_costumer_count, inverse_of: :jobs_as_costumer
|
||||
belongs_to :operator, class_name: "User", optional: true, counter_cache: :jobs_as_operator_count, inverse_of: :jobs_as_operator
|
||||
belongs_to :costumer, class_name: "User", optional: true, counter_cache: :costumer_jobs_count, inverse_of: :costumer_jobs
|
||||
belongs_to :operator, class_name: "User", optional: true, counter_cache: :operator_jobs_count, inverse_of: :operator_jobs
|
||||
belongs_to :creator, class_name: "User", optional: true, counter_cache: :created_jobs_count, inverse_of: :created_jobs
|
||||
belongs_to :cashier, class_name: "User", optional: true, counter_cache: :cashed_jobs_count, inverse_of: :cashed_jobs
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class User < ApplicationRecord
|
||||
has_secure_password
|
||||
# has_many :jobs
|
||||
has_many :jobs_as_costumer, foreign_key: :costumer_id, class_name: "Job"
|
||||
has_many :jobs_as_operator, foreign_key: :operator_id, class_name: "Job"
|
||||
has_many :costumer_jobs, foreign_key: :costumer_id, class_name: "Job"
|
||||
has_many :operator_jobs, foreign_key: :operator_id, class_name: "Job"
|
||||
has_many :created_jobs, foreign_key: :creator_id, class_name: "Job"
|
||||
has_many :cashed_jobs, foreign_key: :cashier_id, class_name: "Job"
|
||||
|
||||
@@ -45,7 +45,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(auth_object = nil)
|
||||
[ "created_at", "email", "firstname", "id", "jobs_as_costumer_count", "jobs_as_operator_count", "lastname", "role", "verified", "name" ]
|
||||
[ "created_at", "email", "firstname", "id", "costumer_jobs_count", "operator_jobs_count", "lastname", "role", "verified", "name" ]
|
||||
end
|
||||
|
||||
def self.ransackable_associations(auth_object = nil)
|
||||
|
||||
Reference in New Issue
Block a user