mercredi 13 septembre 2017

passing argument in has_one association but not passing value its taking model id

form_version.form.check_overflow_form(self.original_effective_date) Form Load (44.1ms) SELECT forms.* FROM forms WHERE forms.parent_form_id = 18338 AND (expiration_date >= 18338 or expiration_date IS NULL) LIMIT 1

here in palce of 18338 need to pass effective_date, below is my code

form.check_overflow_form(self.original_effective_date)

in form.rb

has_one :check_overflow_form, -> (policy_effective_date) { where 'expiration_date >= ? or expiration_date IS NULL', policy_effective_date}, class_name: 'Form', foreign_key: 'parent_form_id', dependent: :destroy

Please give some solution

Aucun commentaire:

Enregistrer un commentaire