Ruby on Rails Monday, February 18, 2013

I have a model Report, and a model ReportComponent. ReportComponent
belongs to Report, and Report has_many components. Both tables have some
commons fields such as organization_id, manager_id etc, and of course
their own unique fields. There is no hard business reason for having
these duplicate fields, but they help with join queries and DB
performance.

The issue i have is that I would like for ReportComponent to
automatically pull organization_id from Report on creation, and store
that in its own field. Not the same as 'AR#delegate' as this would copy
and
write the field.

Best idea i have right now is to override the organization= method, but
that is not foolproof. Is there a native rails method for this?

Thanks,

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment