Displaying 1 result from an estimated 1 matches for "update_units".
2010 Mar 18
5
One-time script to update 1000s of values in a single column in a table: nil error?
...table.
fix_controller.rb
^^^^^^^^^^^^^^^
class FixController < ApplicationController
def index
stocks = Stock.find(:all)
stocks.each do |s|
if s.strength.nil? || s.strength == ''''
puts ''nothing to update''
else
s.update_units
end
end
end
end
Stock.rb
^^^^^^^^^
def update_units
if self.strength == '''' || self.strength.nil?
puts ''nil - cannot update''
elsif self.strength != '''' && self.strength != nil
self.strength = self.strength.gsub!('...