阅读背景:

Rails:如何让模型从父模型“继承”属性?

来源:互联网 

I have a model "Thing" and a model "Category", which have_many of each other through another model "ThingCategories". I want each Category to have a certain set of attributes, and when a Thing is created belonging to that Category, I want the Thing to gain those attributes. For example, if there's a Category called "film" with the attribute :director, and one called "book" with the attribute :author, and I create a Thing called "Harry Potter" which belongs to both categories, then Harry Potter should have both a :director and :author attribute. All I want is both attributes listed on the completed things/show view.I have a model "Thing" and a model "Category",




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: