i building web app in ror need build lot of models, joins etc. models fundamentally same, have similar join models main item , migrations same. not want keep writing code @ end, want generate @ runtime front end possible. eg. models have following attributes - id(default), name, exists? joins has_may :through
so front end if define x model , y model , related @ backend want create teh models , migrations. can feed in data x, y , stored in correct tables.
the controller code standardized , need pass in x,y , want go controller or used it. mean if x related 10 models, in controller need iterate on array containing names of 10 relations. how do this. there way of finding out in controller or in rails relations or joins of model.
what should or study?
my question why need ten models same. , have 2 responses that: 1.) if functionality purposes (i.e. need 10 models perform similar backend functionality) want maybe think wrapping models in module or have them inherit abstract model instead of activerecord:base
. every single 1 of models need migration , own table in database? if not, don't generate migrations. or give them object-relational key in database it's solid architecture.
2.) if need ten models , ten separate tables models (that again, similar , "fundamentally same", might want rethink database architecture. seems redundant me personally, , going huge hassle maintain. example, instead of having bluebaseball, redbaseball, , greenbaseball, why not have baseball, , give type value corresponding key value pair being "green", "blue" or "red".
that's thinking. perhaps don't understand enough problem @ hand though. explain little more models , how program works in object oriented architecture?
Comments
Post a Comment