55 lines
1.3 KiB
Ruby
55 lines
1.3 KiB
Ruby
class EmployerSetupProcess < ApplicationRecord
|
|
has_many :plans, dependent: :destroy
|
|
accepts_nested_attributes_for :plans, allow_destroy: true, reject_if: :all_blank
|
|
|
|
has_many :alternative_network_logos, dependent: :destroy
|
|
accepts_nested_attributes_for :alternative_network_logos, allow_destroy: true, reject_if: :all_blank
|
|
|
|
has_many :card_logo_files
|
|
|
|
before_save :process_employer_logo
|
|
|
|
def process_employer_logo
|
|
unless self.employer_logo.is_a?(String)
|
|
self.card_logo_files.new(
|
|
filename: self.employer_logo.filename,
|
|
logo_type: 'employer',
|
|
image: self.employer_logo.data,
|
|
pl_plan_key: self.pl_plan_key || ""
|
|
)
|
|
end
|
|
end
|
|
|
|
def self.permitted_params(params)
|
|
params.require(:employer_setup_process).permit(
|
|
:employer_name,
|
|
:group_number,
|
|
:pl_plan_key,
|
|
:effective_date,
|
|
:employer_logo,
|
|
:network_provider,
|
|
plans_attributes: [
|
|
:id,
|
|
:title,
|
|
:plan_id,
|
|
:_destroy,
|
|
plan_benefits_attributes: [
|
|
:id,
|
|
:benefit_desc,
|
|
:benefit,
|
|
:sequence,
|
|
:_destroy,
|
|
]
|
|
],
|
|
alternative_network_logos_attributes: [
|
|
:id,
|
|
:network_logo,
|
|
:exception_type,
|
|
:exception_value,
|
|
:_destroy
|
|
]
|
|
)
|
|
end
|
|
|
|
end
|