On Tue, Jan 20, 2009 at 4:14 PM, Sickboy
<pr-VQn6its/Mq7sq35pWSNszA@public.gmane.org> wrote:
>
> Hello,
>
> I''m breaking my head atm about table relations / associations in
> Rails.
>
> The idea is this: Collections has many mods, mods have many folders,
> folders have many items.
> A collection can have many different versions, the mods associated
> with a collection, should ''have the same version''.
> Changelogs are linked to Version, but should differ per Mod.
>
> If I work with ActiveScaffold, things become quite a mess, and I can
> for instance create a Changelog entry, for a mod that is not part of
> the chosen Collection, and so on.
>
> This is basically what I have atm:
> class Collection < ActiveRecord::Base
> has_many :mods
> has_many :versions
> end
>
> class Version < ActiveRecord::Base
> belongs_to :collection
> has_many :changelogs
> end
>
> class Mod < ActiveRecord::Base
> belongs_to :collection
> has_many :folders
> has_many :changelogs
> end
>
> class Changelog < ActiveRecord::Base
> belongs_to :version
> belongs_to :mod
> end
>
> class Folder < ActiveRecord::Base
> belongs to :mod
> has_many :folders
> end
>
> class Item < ActiveRecord::Base
> belongs to :folder
> end
>
> Anybody any ideas? Cheers
>
> >
>
If I''ve understood your problem correctly, I would map the core
relationships as you have described them and then use validation to ensure
the business rules such as a mod of a collection must be of the same version
as the collection.
You can use the validation method or perhaps before_save callbacks depending
on which suits what you''re doing better.
--
Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake
"I have never let my schooling interfere with my education" - Mark
Twain
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---