1

I'm trying to create a form that has:

TextInput--Skill

DropDown--Years Experience

Using jQuery, I have the input and drop down fields populate if a user has more skills to add. Is it possible to store many sets of skills and their respective years experience in a database entry?

I've been looking into has_many:

Thank you!

1 Answer 1

1

No need for extra query here (has_many), look into rails serialization:

class User < ActiveRecord::Base
  serialize :preferences, Hash
end

user = User.create(:preferences => { "background" => "black", "display" => "large" })
User.find(user.id).preferences # => { "background" => "black", "display" => "large" }

You can do the same with Array

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, this makes sense, but I'm confused as to how to change multiple fields into the create method, I think that's where most of my troubles lie.
well, since you're using jquery anyways, you could add the hidden_field to your form and bind the .submit event to it. Once user submits the form, jquery will populate that field with all the [skill, experience] values ( in whatever format you like ). So you'll then have to parse it in your controller

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.