title: In rails, how do I run a column through javascript function to create data for new column?
body: <p>I have 20,000 records in a database with a column titled 'activity' that contains a long json object for each record. I also have a javascript function that will parse thorough the 'activity' json object and return only the information I need. I want to run a class method so that each row will be sent through the javascript function and the return value will be recorded in the 'filtered_activity' column. How do I call this javascript function from the model?</p>
  
  <p>Basically, I want to say..</p>
  
  <pre><code>def self.filter_data
    leads = Lead.all
    leads.each do |lead|
      response = javascriptFunction(lead.activity)      
      lead.update(filtered_activity: response)
    end
  end
  </code></pre>
  
  <p>Thank you!!</p>