New Discussion

Notifications

You’re not receiving notifications from this thread.

accepts_nested_attributes_for and :reject_if

0
Rails

Hello everybody!
I have problem with nested attributes:.

My model:

class MainTransactionElement < ApplicationRecord
    has_one :external_source
    accepts_nested_attributes_for :external_source, :reject_if => :is_external_source_blank?
end

    def is_external_source_blank?
        is_external_source_checkbox == '0'
  end

During the first load of form, it works. But is one bug:

  1. Checkbox is unchecked and form won't pass the validation and render again.
  2. In next render form doesn't generate nested attributes and I check checkbox.
  3. In next render, nested attributes still doesn't generate, despite the previously marked checkbox.

Any ideas why?

Join the discussion
Create an account Log in