Skip to content

Instantly share code, notes, and snippets.

Created April 11, 2014 15:36
Show Gist options
  • Save anonymous/f811f5caad041b532797 to your computer and use it in GitHub Desktop.
Save anonymous/f811f5caad041b532797 to your computer and use it in GitHub Desktop.
class NewProduct < ActiveRecord::Base
validates :name, presence: true
end
l_name_var = " "
@products = NewProduct.where("new_products.name LIKE :l_name", {:l_name => "%#{l_name_var}%"})
puts @products.count
@products.each do |product|
@aproduct = NewProduct.find_by(:id => product.id)
if @aproduct.name[0] == " "
old_name = @aproduct.name
begin
binding.pry
@aproduct.name.slice!(0)
binding.pry
@aproduct.save
puts "From: #{old_name} => #{@aproduct.name}"
rescue => error
binding.pry
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment