title: Pass variable from Controller to Serializer in Rails
body: <p>I have this code in my Controller to get distance in meters from one location to another location:</p>
  
  <pre><code>range = Geocoder::Calculations.distance_between([lat,lng],[Model.location.lat,Model.location.lng])
  rangeInMeters = range * 1000            
  rangeRounded = rangeInMeters.round
  rangeRounded = rangeRounded / 100 * 100
  </code></pre>
  
  <p>and I have this code in my serializer to give a nicer output for the json response like this:</p>
  
  <pre><code>class ModelSerializer &lt; ActiveModel::Serializer
    attributes :id, :name, :address, :range
  
    def range
    // something
    end
  end
  </code></pre>
  
  <p>How to get rangeRounded be read by ModelSerializer so in json response it would be like this:</p>
  
  <pre><code>{
          "id": 1,
          "name": "Name A",
          "address": "Address A",
          "range": 500
      },
  </code></pre>