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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -