开发者

Ruby on Rails multidimensional array-like storage

开发者 https://www.devze.com 2023-02-26 04:28 出处:网络
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 s

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

精彩评论

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

关注公众号