title: rails callback before 'new' of a model?
body: <p>I have a model <code>base_table</code>, and I have a <code>extended_table</code> which has extra properties to further extend my <code>base_table</code>. (I would have different extended_tables, to add different properties to my base_table, but that's non-related to the question I'm asking here).</p>
  
  <p>The model definition for my <code>base_table</code> is like:</p>
  
  <pre><code>class BaseTable &lt; ActiveRecord::Base
    module BaseTableInclude
      def self.included(base)
        base.belongs_to :base_table, autosave:true, dependent: :destroy
        # do something more when this module is included
      end
    end
  end
  </code></pre>
  
  <p>And the model definition for my <code>extended_table</code> is like:</p>
  
  <pre><code>class TennisQuestionaire &lt; ActiveRecord::Base
    include BaseTable::BaseTableInclude
  end
  </code></pre>
  
  <p>Now I what I want is the code below:</p>
  
  <pre><code>params = {base_table: {name:"Songyy",age:19},tennis_ball_num:3}
  t = TennisQuestionaire.new(params)
  </code></pre>
  
  <p>When I created my <code>t</code>, I want the base_table to be instantiated as well.</p>
  
  <p>One fix I can come up with, is to parse the params to create the base_table object, before TennisQuestionaire.new was called upon the params. It's something like having a "before_new" filter here. But I cannot find such kind of filter when I was reading the documentation.</p>
  
  <p>Additionally, I think another way is to override the 'new' method. But this is not so clean.</p>
  
  <p>NOTE: There's one method called <code>accepts_nested_attributes_for</code>, seems to do what I want, but it doesn't work upon a <code>belongs_to</code> relation.</p>
  
  <p>Any suggestions would be appreciated. Thanks :)</p>