Ruby on Rails
Monday, November 5, 2018
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment