I am probably missing something, so please help:
I have a table called ‘zipped_responses’ with an ‘item_names’ varchar
I want to create a comma separated string of ‘names’.
I have an ‘add_item_names’ method which takes a ‘name’ and put it at the
of a string with a preceding comma.
The model goes like this:
class ZippedResponse < ActiveRecord::Base
def add_item_names (name) str = read_attribute(:item_names) str << "," unless str.empty? str << name write_attribute(:item_names, str) end
Now in the console, I write
and I get:
z.item_names => “aa”
Fine until here. Now I write:
and to my suprise I get that in z1, the ‘item_names’ attribute has also
value “aa” !!
(z1.item_name => “aa”)
How come ??