Skip to content

Instantly share code, notes, and snippets.

@Alir3z4
Created April 5, 2011 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Alir3z4/904121 to your computer and use it in GitHub Desktop.
Save Alir3z4/904121 to your computer and use it in GitHub Desktop.
Improved one base on condition, bad coding but it's work
# Improved one base on condition, bad coding but it's work!
def number_list=(numbers_string)
self.numbers.destroy_all
numbers = numbers_string.split(",").collect{|num| num.strip.downcase}.uniq
numbers.each do |number|
unless !self.save
num = self.numbers.find_or_create_by_content(number)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment