title: Cascade update on association
body: <p>I have a class <code>Yojana</code> and another class <code>Kabuliyat</code>, where Kabuliyat belongs to Yojana, and a Yojana has one kabuliyat.</p>
  
  <pre><code>class Yojana &lt; ApplicationRecord
    has_one :kabuliyat, dependent: :destroy
  end
  </code></pre>
  
  <pre><code>class Kabuliyat &lt; ApplicationRecord
    belongs_to :yojana
  end
  </code></pre>
  
  <p>Some of the fields/attributes of a <strong>kabuliat instance</strong> are dependent on the attributes of the <strong>yojana instance</strong>. </p>
  
  <p>For example in partial form for a <strong>new kabuliyat</strong>.</p>
  
  <pre><code>- @yojana = Yojana.find_by_id(params[:yojana_id])
  
  = form_for kabuliyat do |f|
  tr
      td = f.label :yojana_name
      td = f.text_field :yojana_name, {value: @yojana.yojana_name,class: "hide-input",:readonly =&gt; true}
  
  tr
      td = f.label :mukhya_samiti
      td = f.text_field :mukhya_samiti, {value: @yojana.mukhya_samiti,class: "hide-input",:readonly =&gt; true}
  
  </code></pre>
  
  <p>As you can see, the attributes such as <strong>:yojana_name</strong> and <strong>:mukhya_samitit</strong> for a kabuliyat instance are extracted from it's parent yojana instances attribute.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>I wanted to know, if I had an instance of kabuliyat saved, and then I edited the Yojana's instance on whom the Kabuliyat's attributes are dependent on, how would I be able to also reflect the changes on the kabuliyat's instance.</p>
  
  <p><em>For example</em>: If I change the name of a Yojana instance from "A" to "B", can this change be automatically reflected on the child instance kabuliyat's attribute(for example: yojana_name) automatically.</p>
  
  <p><strong>What I have tried:</strong></p>
  
  <p>I used the <code>before_update</code> callback in the <strong>Yojana.rb</strong> model class, and manually made changed to all the other depended classes on Yojana. I wanted to know if there was any other efficient method.</p>