开发者

Ruby on Rails multidimensional array-like storage

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 databa开发者_Python百科se entry?

I've been looking into has_many:

Thank you!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜