开发者

Enabling 2 different models in a rails app talk to the same table

I'm having a few integration issues. I have 2 models which need to be开发者_JAVA百科 mapped so as to enable them to talk to the same table. So one model has a few attributes that are mapped to the corresponding columns in the table and likewise for the other model.

I've heard of aliasing, a technique that can be used. Help would be appreciated. Thanks !


You create your two model and define the same table_name

  class ProjectComplete < ActiveRecord::Base
    set_table_name "projects"
  end

  class ProjectLittle < ActiveRecord::Base
    set_table_name "projects"
  end
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜