ruby - Rails: How to get a model to "inherit" attributes from a parent model? -
i have model "thing" , model "category", have_many of each other through model "thingcategories". want each category have set of attributes, , when thing created belonging category, want thing gain attributes. example, if there's category called "film" attribute :director, , 1 called "book" attribute :author, , create thing called "harry potter" belongs both categories, harry potter should have both :director , :author attribute. want both attributes listed on completed things/show view.
so far i've created "attribute" model , 2 connecting models "thingattribute" , "categoryattribute", i'm not sure go here. on right track?
i'm using rails 4.0.10.
how i'd this..
i'd create attributes parts of module. have book_helper.rb , movie_helper.rb
i'd import right file during initialise function. object specific.. when doing i'd consider name-spacing methods don't clash.
i'm not sure if right way, how i'd go (unless told me improve way)
ruby-on-rails ruby ruby-on-rails-4 model parent-child
No comments:
Post a Comment