Is it possible to save multiple select values into one table sell?

<SELECT MULTIPLE SIZE=4>
<OPTION VALUE="A">Option A
<OPTION VALUE="B">Option B
<OPTION VALUE="C">Option C
<OPTION VALUE="D">Option D
</SELECT>

I know, there should be two tables, but... there is 3 miljons rows in
table and 99% of rows has only one select value..

So is it possible to make something like this:

data (id, name, select)

1, "xxxx", "A"
2, "xxxx", "B"
2, "xxxx", "A,B"

Some "hack" to forms and controller?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Dec 11, 2011 at 9:39 am

    On 11 December 2011 08:59, Fresh Mix wrote:
    Is it possible to save multiple select values into one table sell?

    <SELECT MULTIPLE SIZE=4>
    <OPTION VALUE="A">Option A
    <OPTION VALUE="B">Option B
    <OPTION VALUE="C">Option C
    <OPTION VALUE="D">Option D
    </SELECT>

    I know, there should be two tables, but... there is 3 miljons rows in
    table and 99% of rows has only one select value..

    So is it possible to make something like this:

    data (id, name, select)

    1, "xxxx", "A"
    2, "xxxx", "B"
    2, "xxxx", "A,B"

    Some "hack" to forms and controller?
    Forget about forms and controllers initially, just think about how to
    store the data in the database. The rest can come later. One option
    would be use a bit field for the selections, so A would be represented
    by binary 001, B by 010, C by 100 and so on, then for A and B the
    value would be 011. I believe there are gems available that will
    handle this for you though I have not used them. Google for
    rails bitfield
    shows a number of hits that look useful.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Brynjolfur Thorvardsson at Dec 11, 2011 at 9:55 am
    Hi all

    I'm hoping to play around with Rails and Adhearsion but I find it very hard to get started. Does anybody know about a good starting point on the web or perhaps an example application code, perhaps on git?

    Thanks in advance

    Binni

    ITAnet
    Kirkestien 20
    9230 Svenstrup

    Telefon: 3020 0868

    Email: binni@itanet.nu
    WWW: http://www.itanet.nu





    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedDec 11, '11 at 8:59a
activeDec 11, '11 at 9:55a
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase