title: How can I extend ActiveRecord model with new propery?
body: <p>I'm developing a REST API and before send results (fetched from DB with ACtiveRecord) to client I need to extend it with some additional data. Here is how I suppose it to be:</p>
  
  <pre><code>  def index
      (categories = Category.all()).each() do |category|
        category.image = "some image"
      end
      render json: categories
    end
  </code></pre>
  
  <p>It seems like Ruby does not add object proporties on the fly, like JS would do, so this code ends up with error message</p>
  
  <pre><code>undefined method `image=' for #&lt;Category:0x007f89f0513d40&gt; 
  </code></pre>
  
  <p>I read a lot and found solution to add <code>attr_accessor :image</code> in my <code>Category</code> model. Now it does not throw error but also <code>image</code> property does not appeared in JSON output.</p>