Hi,

On Monday, April 28, 2014 9:31:06 PM UTC+2, Matt Jones wrote:
>
>
> This doesn't make any sense to me - if I request a ReportsSubject object 
> from the database directly (via `find`, for instance), what do I get if I 
> ask for its subject? What would the reports_subjects table even *store*? A 
> bare `subject_id` would be insufficient since without a class_name it's 
> unclear what table that ID refers to.
>

A "report subject" (a row in the join table) doesn't carry any semantics 
without the report, which has further information about required details. A 
report also only ever has a single type of subject, so IMO it would not 
make sense to store a couple thousand repetitions of an STI name (although 
note that the subjects are not all part of a single STI hierarchy!) in a 
column that adds no information at all to the system.
 

> And that's not even considering what should happen when this sort of code 
> runs:
>
> Report.joins(:subjects).where(name: 'hey wait WHAT TABLE IS THIS EVEN 
> QUERYING')
>

This is not functionally different from having the polymorphic subject type 
specified in the join table.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/46a7c7a0-8bc1-4956-ad84-cbbd85d5b19b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to