Hi everyone,

I'm a newer developer to both Radiant and Rails - first of all want to thank
you all for making such an awesome CMS, its been a joy to work with so far
and the extensions system in particular is genius and very well
designed/implemented.

I have a question however, related to Radiant and models which I'm hoping
someone here can answer. To illustrate my point imagine I have two entities:

   1. Speakers (lecturers/panelists/etc.)
   2. Videos (videos of those speakers/panelists giving a lecture)

What I need to do is be able to relate these two models in the following
way:

   - Speaker belongs_to Video
   - Video has_many Speakers (eg. in the case of a panel discussion)

Basically each Speaker will have his own page detailing things about the
speaker (name/etc.), and subsequently each lecture will have its own "Video"
page detailing things about the video (description/etc.) BUT each Video page
will also contain a list of Speakers that are featured in that video.  (This
needs to reference the Speakers model)

So far, I've gotten so far as to follow the Custom-Page-Type tutorial (
http://wiki.github.com/radiant/radiant/creating-a-custom-page-type) which
has been helpful, and now I have two custom page types up and running.  The
problem with this is that it sticks all the additional "custom fields" in
the same table as the :pages model.  So any given page will have all those
columns (if it is of type Speaker, then the Video columns will be nulled
etc.)

This is all fine and dandy... except when you want to do associations as I
mentioned above.  I'm wondering is there a way to implement this properly?
 What I observed from looking at the way the comments extension was done is
that a Comment < ActiveRecord::Base and then had a foreign key to the Page
model (using belongs_to).  Then in the comments_extension.rb it uses the
"Page.class_eval" method to put in associations to the Page model.  I then
thought that I could perhaps do something similar in my situation, but the
challenge that I have is that both of those entities MUST be page-types and
not thus inherit from < Page as opposed to purely from < ActiveRecord::Base.


So then I'm currently stuck there - with some sort of thought of perhaps
somehow doing... a foreign key from the "Pages" table to a new ActiveRecord
"Speakers" table which would contain all the information?  And then when
setting the video, somehow pulling speakers from the Speakers model to
populate a list or something that they can choose from?  In theory this
makes sense in my head, but I'm lost as to how to actually implement it
properly in Radiant/Rails.

Any help with this would be of great help - thanks everyone!

Sincerely,
-Derek
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
List Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Radiant: http://radiantcms.org
Extensions: http://ext.radiantcms.org

Reply via email to