title: How to get parent data if child data does not exist
body: <p>I am trying to get the child data if it exists but when it is nil it will get the parent data.</p>
  <p>I don't want to hard code this in the view's because this would require something like:</p>
  <pre class="lang-rb prettyprint-override"><code>if @product.parent
    @product.price ? @product.price : @product.parent.price
  end
  </code></pre>
  <p>So I thought it would be better to put something in the product model to override that specific attribute like:</p>
  <pre><code># app/models/product.rb
  def price
    if self.parent
      self.price ? self.price : self.parent.price
    end
  end
  </code></pre>
  <p>But the way above would be ver redundant because i would have to do that for every attribute that model has which would be a lot of functions.</p>
  <p>Is there any way to make a function that is going to do the same functionality that would apply to all attributes?</p>
  <p>I want to be able to get any attribute from the parent if it is not available from the child</p>
  <p>Thanks</p>