ruby on rails - delete dash character which is at the end of the string -
so have table items in db. want in item.name replace -
character @ end of item.name
try this:
items = item.all items.each |it| it.name=it.name.gsub('/\-$/','') it.save end
but doesn't work. do?
upd: managed this:
i = item.all i.each |it| it.name=it.name.chomp('-') it.save end
but still don't why first variant didn't work
try below 1 definatly work you.
items = item.all items.each |item| item.name = item.name.gsub('-','') it.save end
Comments
Post a Comment