update all records

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

update all records

fugee ohu
I'm trying to iterate through all records and strip out non-numerics or non-digits from the 'contacts' column which contains phone numbers with unwanted characters After that I need to remove any leading 1's from the beginning of the string I didn't try to remove the 1's yet I'm stuck at stripping the non-numerics out still Here's my code:

messages=Sm.where("contact is not null")
messages.each do |msg|
msg.contact.delete('^0-9')
msg.save
end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/52999c5e-12e3-40a7-a70a-20dd442dd356%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.