0

I read I can use this:

SomeModel.update_all name: 'my name'

To make a batch transaction. Is it possible to make this change using the actual value in each row?

Example:

some_models
name
'asd'
'qwe'

A code that allows me to get:

some_models
name
'asd another'
'qwe another'

?

sites
  • 21,417
  • 17
  • 87
  • 146

1 Answers1

1

You need to do this at database level.. Here's how to do it in postgresql

UPDATE table_name SET column_name = column_name || 'yo';

and in MySQL(not tested)

UPDATE table_name SET column_name = CONCAT(column_name ,'yo');
benchwarmer
  • 2,764
  • 23
  • 25
  • another thing, how can I update two fields at once? I mean in SQL? – sites Jul 19 '13 at 16:39
  • thanks, to update several columns: http://stackoverflow.com/questions/2427010/how-to-update-two-columns-in-a-mysql-database – sites Jul 19 '13 at 16:56