Treid get_field
def changeset(job_opening, attrs) do
job_opening
|> validate_number(:minsalary, greater_than: 0, message: "Min. Salary should be greater than 0")
minsalary = get_field(job_opening, :minsalary)
|> validate_number(job_opening, :maxsalary, greater_than: minsalary, message: "Max. Salary should be greater than Min. Salary")
end
but getting Error that is undefined function minsalary/0
When I comment out these error-prone lines and inspect the job_opening, here is what I get
%Apollo.JobOpening.Schema.JobOpening{
__meta__: #Ecto.Schema.Metadata<:loaded, "public", "job_openings">,
applicants: #Ecto.Association.NotLoaded<association :applicants is not loaded>,
applied_openings: #Ecto.Association.NotLoaded<association :applied_openings is not loaded>,
company_admin: #Ecto.Association.NotLoaded<association :company_admin is not loaded>,
company_admin_id: 1,
description: "<p><strong>Join [Company] as a [Position]!</strong></p><p>We're looking for an experienced [Position] to come in and help us take our team to the next level.</p><p>To apply, take this <strong>[TimeLimit] minute test</strong>. All questions can be <strong>answered multiple times</strong>. And you will get rapid <strong>feedback</strong> after finishing.</p><p>You can take the test <strong>only once</strong>.</p>",
duration: 900,
employment_type: "Full Time",
failure_message: "<p><strong>Thanks! You scored [TestScore]!</strong></p><p>No worries. A real human at [Company]. will now go through everything you sent. If you’re chosen for the next round, we'll share the good news by [7DaysFromApplying].</p><p>Talk to you soon!</p><p>[Admin] from [Company]</p>",
id: 7,
inserted_at: ~N[2019-05-19 17:08:32],
is_public: false,
job_stages: #Ecto.Association.NotLoaded<association :job_stages is not loaded>,
maxsalary: #Decimal<10>,
minsalary: #Decimal<10000>,
name: "Machine Learning Engineer II",
questions: [],
share_url_route: "i2eJPs6hTM4ErdNCUbhB",
skills: ["Deep Learning", "Data analysis", "python", "Data structure"],
success_message: "<p><strong>Great start! You got [TestScore]!</strong></p><p>A real human will now go through everything you sent. If you’re chosen for the next round, we'll share the good news soon. If the journey stops here, we’ll also confirm that.</p><p>Talk to you soon!</p><p>[Admin] from [Company]</p>",
test_required: true,
threshold: 50.0,
updated_at: ~N[2019-05-19 17:08:32],
workspace: #Ecto.Association.NotLoaded<association :workspace is not loaded>,
workspace_id: 1
}