title: Accessing Variables in Rails 3 before_save Method
body: <p>I have the following <code>before_save</code> method:</p>
  
  <pre><code>def get_data
    url = "http://www.api-fetching-url.com/where_my_data_input_is=#{self.my_data}&amp;output=json"
    new_data = HTTParty.get(url)
    @field_to_update = new_data['one']['two']['here']
    self.field_to_update = @field_to_update
  end
  </code></pre>
  
  <p>Unfortunately, the <code>self.my_data</code> doesn't appear to be working, because the JSON url doesn't produce any result. But, when I substitute <code>my_data</code> in the hardcoded way, it works just fine. Moreover, I can do a <code>find</code> in the Rails console and get the <code>my_data</code> field just fine. So, it's not an issue with that field not saving or something on the form side.</p>
  
  <p>Is there an issue inserting data this way in a <code>before_save</code> method? If not, is there a different way of doing this that I'm missing?</p>