Let me see if I understand... In the GENRE table you might have a genre
named "Western", with GENRE_FIELDS "Good Guy", "Bad
Guy", and "Town".
The genre fields "Good Guy" and "Bad Guy" would have a link
to the
CHARACTERS table, while the genre field "Town" would have a link to
the
LOCATIONS table. In the code, you want to be able to do something like this:
westerns = Story.find_by_genre("Western")
westerns.each do |western|
  western.genre.name        -> "Western"
  western.genre.fields      -> ["Good Guy" => character_object,
                                "Bad Guy" => character_object,
                                "Town" => location_object]
  western.genre.fields["Good Guy"].first_name  -> "Tex"
  western.genre.fields["Bad Guy"].first_name   -> "Bart"
  western.genre.fields["Town"].loc_name        ->
"Tombstone"
  western.genre.fields.each do |field, ob|
    str += "The #{field} for #{western.title} is #{ob.to_s}<br>"
  end
end
Is this correct?
Elf M. Sternberg wrote:> For my first Ruby app, I''m writing a plot management tool for 
> screenwriters and authors.  And the SQL for it is rather fun (I actually 
> drew my first ERD in ten years) and one of the problems I''m having
is
> integrating the GENRE class with the WORLD class.
> 
> To explain: Authors have Worlds.  Worlds have Stories, Stories have 
> Plots, Plots have Scenes.  Worlds also have Characters and Locations. 
> Scenes have a Location and many Characters.
> 
> Much of what goes into a story is commentary: hair color, eye color, 
> height, weight, etc.  I''m trying to do some nifty handling whereby
when
> you type a character''s name in the "narrative" box the
character''s bio
> will automagically be displayed in a DIV in an upper box (perhaps an 
> inset, not sure about that yet).   Some details are GENRE related.
> 
> I want GENRE to be dynamic: GENRE has GENRE_FIELDS (id, name, 
> description), which are cross-indexed with the table type ("does this 
> field belong to the Character table, or the Location table?").
> 
> Is it possible to use a table''s _name_ as a foreign key, and how
would I
> access that from within Rails?
> 
> (If the answer to this is yes, then I''ll have what I need to also 
> correlate TABLE_ID,CHARACTER_ID,GENRE_FIELD_ENTRY_ID, and display the 
> correct data along with the correct label.)
> 
> Elf
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>