So I have table items in my db.
I want in Item.name replace -
character which is at the end of the Item.name
So I try to do it like this:
items = Item.all
items.each do |it|
it.name=it.name.gsub('/\-$/','')
it.save
end
But it doesn't work. What do I do?
upd: I managed to do it like this:
i = Item.all
i.each do |it|
it.name=it.name.chomp('-')
it.save
end
But still don't get why first variant didn't work