Activerecord Realtionship question

Hi John,

John Butler wrote:

If i have a model called sample and each sample has_many
actions. So i have a table called samples filled with different
samples and a table called actions filled with different actions.
I used both has_many through and habtm to get this to work
with join tables.

Based on what you've said, all you need is a simple has_many / belongs_to relationship between the two. You don't need a join table.

Now there is a field called additional_comments that is associated
with actions so if you could imagine a form with a number of actions
and then one big textfield called additional comments to add some
text. where do i put this field additional_comments, it doesnt really
belong in the samples table because its additional comments about
the actions.

Again, based on what you've said, all you need to do is add the field to the actions table.

hth,
Bill

sample has_one action_group
action_group belongs_to sample
action_group has_many actions
actions belong_to action_group

samples

ok., so your actions is a lookup list, i didn't realize this. you're
going to need another table to hold the relationships between samples
and actions and want to know the best solution to attaching comments
to the group of actions as a whole, rather than to each comment

i don't see a problem with putting the comments field in the samples
table. its comments about the actions for THAT sample. unless of
course you want to be able to have groupings of actions to have the
same comments across multiple samples, but you dind't mention that so
I will assume that is not the case.

so i believe the consesus is to put the comments field in the samples table.