storing and retrieving arrays in mysql using rails


  I have a multiple checkbox of values 1 to 7 for selecting weekdays.

  What is the possibility of storing the selected weekdays array in
  and what type of field should i create in the table for storing the
  Any suggestions???

Vimal Das

nothing extra tweaks are required to achieve this.

<%= select_tag "days[]", options_for_select([ "Mon", "Tue", "Wed", "Thu","Fri","Sat","Sun",], "Monday"),:multiple => true %>           

This would ensure that your selection is stored into array “days[]”.
You can store this as string into db with a delimiter of your choice [preferably days.join(",")].

hope it was useful, else post me more details :slight_smile:

Cool suggestion :slight_smile:
Thanks! Sumanth