I have a list coming in a field like :selected_lists => [1,2,3,4]
from a form
while storing it in a database i need to join this list into a
so then in my model class,
- Added a filter before_save :convert_array_to_string
- Added an attr_accessor :selected_lists
self.lists_selected = self.lists_selected.join(",")
so that before saving i call a function to format the array to
string and store it using attr_accessor method
I printed the “self.lists_selected” and i got “1,2,3,4” as the
I thought this would do my job
I am wondering why ‘nil’ is stored in the table.
Please help me out off this guys.