Doesn't matter if the column comes statically or dynamically. The presence 
of the "type" virtual-column in the record should be enough.

 record[inheritance_column].present?

instead of

record[inheritance_column].present? && columns_hash.include?(
inheritance_column)

What do you think?


On Tuesday, June 10, 2014 4:35:11 PM UTC+3, Xavier Noria wrote:
>
> On Tue, Jun 10, 2014 at 2:53 PM, Ivailo Bardarov <[email protected] 
> <javascript:>> wrote:
>
> By virtual we mean that we don't have the 'type' column in the DB at all. 
>> We determine it runtime via scope from the query.
>>
>> Here is an example https://gist.github.com/gudata/7ff43e3b6600408b1c1e
>>
>
> I don't quite see that in core.
>
> AR does not have as a goal to support "inheritance" in a generic way. 
> Rather, AR has STI baked in, where STI is a very concrete portable pattern:
>
>     http://martinfowler.com/eaaCatalog/singleTableInheritance.html
>
> I believe trying to generalize the implementation of STI to fit other 
> designs in would not be a good idea. The design of STI should model STI.
>
> Rather, I see here a plugin that specifically models table inheritance as 
> done in Postgres.
>
>
> multi_table_inheritance 
>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fninjudd%2Fmulti_table_inheritance&sa=D&sntz=1&usg=AFQjCNEOoIsa4h8OtebcAb119NEEy0wPAw>
>>  is 
>> very old and probably is not addressing the same problem.
>>
>
> Yeah it's old and talks about Rails 2.3 in the README. I mentioned the 
> plugin only because it might be relevant and a plugin author could perhaps 
> check the implementation and see if they could copy some idea from it.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to