Suresh Kumar
2014-Nov-13 10:34 UTC
Rails4 - How to design model to save multiple items for a table's column?
I have a user model with name, email and password. Now I want to add languages know by the user to the user model. I can do that by the following rails generate migration add_languagesknown_to_users languagesknown:string But I want the user to have the capability to store multiple languages. Some users will know only one language some might know 10. And, I have a view to search all users when the search button is clicked. But later I want to search users using languages known field. Can someone kindly share on how do I create a migration for such use? For instance, a user "Sam" signs up with English and Spanish as known languages; when users search for users who know English, Sam should be listed; when users search for users who know Spanish, Sam should be listed. How do I create a migration for this? Should i create a table of languages and associate it with the user model? Can anybody share how please? -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ed53ace8108d9056fd0580ad6526a4da%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.