I'm wondering how I can normalize my tables in rails, say I've got a table containing id, username, email and an optional field (often left blank). I would like to m开发者_Go百科ove out this optional field into a separate table but still use it as a attribute in the model. Is this possible?
class Something belongs_to :other delegate :other_field, :to => :other, :allow_nil => true end
Look at delegation: http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/
精彩评论