Hello! New to ruby on rails, so I hope this isn''t a stupid question (great way to start a post ;)). Basically I''m trying to avoid making a bunch of different columns in my db table by having my collection_select concatenate the ID value it returns to a single text field (for instance, the collection_select will return a footnote ID, and I would like to keep it in a job column called footnote) with comma''s in between because each job has multiple footnotes. Is there any way I can accomplish this ? Ideally I would like to put comma''s in between so I can break it apart in another area of my program. Thank you for any help. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bee Dubya wrote:> Hello! > > New to ruby on rails, so I hope this isn''t a stupid question (great way > to start a post ;)). Basically I''m trying to avoid making a bunch of > different columns in my db table by having my collection_select > concatenate the ID value it returns to a single text field (for > instance, the collection_select will return a footnote ID, and I would > like to keep it in a job column called footnote) with comma''s in between > because each job has multiple footnotes.DO NOT DO THAT. You need two tables with a has_many/belongs_to relationship. You should never ever put multiple values in one field.> > Is there any way I can accomplish this ? Ideally I would like to put > comma''s in between so I can break it apart in another area of my > program.Don''t. Read up on proper database normalization, and do it right.> > Thank you for any help.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote:> Bee Dubya wrote: >> Hello! >> >> New to ruby on rails, so I hope this isn''t a stupid question (great way >> to start a post ;)). Basically I''m trying to avoid making a bunch of >> different columns in my db table by having my collection_select >> concatenate the ID value it returns to a single text field (for >> instance, the collection_select will return a footnote ID, and I would >> like to keep it in a job column called footnote) with comma''s in between >> because each job has multiple footnotes. > > DO NOT DO THAT. You need two tables with a has_many/belongs_to > relationship. You should never ever put multiple values in one field. > >> >> Is there any way I can accomplish this ? Ideally I would like to put >> comma''s in between so I can break it apart in another area of my >> program. > > Don''t. Read up on proper database normalization, and do it right. > >> >> Thank you for any help. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.orgIn connection with this, and at the risk of reviving a dead thread: a big part of database normalisation is atomising your data. This enables you to better acclimate your application to future alterations and more effective database requests. Searching is a good example of this - I am simply reinforcing Marnen''s point regarding database normalisation. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.