Andrew M. Campbell
2005-Mar-12 19:29 UTC
"belongs_to" associated decided by another value in the model?
I have a model called "review". It has a belongs_to attribute called "art_form". I want to setup another belongs_to attribute called "art", but it needs to be based on the value of "art_form". In other words, the class that the "art" belongs_to association points to is decided by the value of "art_form". Is this possible? If it is not do you have any suggestions on how something similar could be done? If this does not make any sense, I apologize. If you want to look at my crappy diagram, go here: http://andrewc.mdns.org/print.pdf Thank you, Andrew M. Campbell
Caleb Buxton
2005-Mar-12 20:02 UTC
Re: "belongs_to" associated decided by another value in the model?
Hi, Are the different "art" type definitions really that divergent? What if you tried to develop a more abstracted "art" class that could maybe meet the needs of all the different forms of art... And at some other level, maybe like a view or a helper, handle the abstracted "art" attributes differently based on the art_form. So, for example, lets say your "art" class has an asset attribute. For an "art" instance with "art_form" of portrait you''d handle it like a jpg, for a sculpture, perhaps a 3d model. I dunno -- I just feel like the associations between models needs to be hard, and have the data and the way you handle it flexible. my 2 cents -Caleb On Sat, 12 Mar 2005 11:29:10 -0800 (PST), Andrew M. Campbell <listdata-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote:> I have a model called "review". It has a belongs_to > attribute called "art_form". I want to setup another > belongs_to attribute called "art", but it needs to be > based on the value of "art_form". In other words, the > class that the "art" belongs_to association points to > is decided by the value of "art_form". Is this > possible? If it is not do you have any suggestions on > how something similar could be done? > > If this does not make any sense, I apologize. If you > want to look at my crappy diagram, go here: > http://andrewc.mdns.org/print.pdf > > Thank you, > Andrew M. Campbell > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Andrew M. Campbell
2005-Mar-12 22:33 UTC
Re: "belongs_to" associated decided by another value in the model?
--- Caleb Buxton <adbust-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I dunno -- I just feel like the associations between > models needs to > be hard, and have the data and the way you handle it > flexible. > > my 2 centsI took your advice. I''ve made it much further now. I appreciate you taking the time to give your 2 cents worth. Thanks, Andrew M. Campbell