Storing multiple checkbox values in database
Posted
by Madjokr
on Stack Overflow
See other posts from Stack Overflow
or by Madjokr
Published on 2010-04-09T05:15:40Z
Indexed on
2010/04/09
5:23 UTC
Read the original article
Hit count: 296
Hi, I want to store multiple column values in table.Lets take a example .. What are your favourite colors? the choices can be red,blue,green, orange. So lets assume, the user selects atleast 2 values.
Is there any way to store the multiple values in table. I have implemented by concatinating choices of users in a column in the table. I later found that it is a bad practise.
Currently i can think of using Bitwise operator and habtm.
What are the different ways for storing multiple choices values in table? If I am implementing in rails, What is the best way to implement this with OOP concepts? Is there any builtin options in rails?
© Stack Overflow or respective owner