Hello,
I'm using a session variable to store a list of IDs during a session.
Basically, a user selects many options from a group of checkboxes, and I save that in a session variable.
When I retrieve the session variable and set a model's variable to that value, it works fine.
For instance:
<input type="checkbox" name="user_profile[language_ids]" value="1" /
Language 1
<input type="checkbox" name="user_profile[language_ids]" value="2" /
Language 2
<input type="checkbox" name="user_profile[language_ids]" value="3" /
Language 3
<input type="checkbox" name="user_profile[language_ids]" value="4" /
Language 4
<input type="checkbox" name="user_profile[language_ids]" value="5" /
Language 5
I set session[:language_ids] = params[:user_profile][:language_ids]
When I retrieve that: @user_profile.language_ids = session[:language_ids] and I save it, it works fine.
My problem is...I want to store those values in a database, but just in 1 field.
So I created a string type field and save it. But the value looks strange on the way out of the DB and I can't set the @user_profile.language_ids to that value.
Is there a trick to saving this kind of a list of IDs to a DB field?
Thanks, Andy