Does seem to be a bit of repetition in your description but it seems
straightforward.

You have a Module which has an Entity_type column

Each Module has many Chapters where Chapters has a column named
module_id.

Each Chapter has many Activities with similar foreign key constraints
or
You have one Activities table, in which case you don't specify a
relationship.

Once you set up the has_many and belongs_to pairs, Rails provides the
methods to interact with the data.

Checkout some ActiveRecord tutorials like this screencast -
http://www.railsenvy.com/2007/8/8/activerecord-tutorial

On Jun 6, 10:29 pm, Ritvvij <[email protected]> wrote:
> Hello guys,
>
> Need help!! Finding it hard to model the 'model' :P within the given
> rails associations.
>
> In java terms, my requirements are...
>
> There are 3 entities - module, chapter and activity.
>
> Chapter entity is a specilization of Module entity (inheritence)
> Activity entity is a specialization of Module entity (inheritence)
> And the tables would have looked like:
> 1. Module table = Module_Id, Entity_type, ....
> 2. Chapter = Chapter_id, .....
> 3. Activity = Activity_id, ......
>
> Hence, if I create a chapter then the tables would be populated as:
> Module table = Module_Id, Entity_type, .... = values ( 100,
> chapter , .... )
> Chapter table = chapter_id, ..... = values ( 100, .... )
> Basically, the ids of chapter and module would be same and module
> table would store the type.
>
> Now, if I create a activity then the tables would be populated as:
> Module table = Module_Id, Entity_type, .... = values ( 101,
> activity , .... )
> Activity table = activity_id, ..... = values ( 100, .... )
> Basically, the ids of activity and module would be same and module
> table would store the type.
>
> Can you please guide me how I can model it similarly in rails 2.3.2?
>
> Thanks in advance
> Ritvvij Parrilkh
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to