As great as Rails 2.1 is, I for the life of me cannot figure out why
polymorphic associations do not support reconfiguring the type column
used.

For example, I have no way to do a polymorphic association using a
lookup hash which maps an integer to a class name.

Storing a TINYINT unsigned is waaaaay more efficient than storing a
string like "SomeActiveRecordModel" over and over again.

Looking in the association proxy classes for has_one and has_many, I
see:

      def construct_sql
        case
        when @reflection.options[:as]
          @finder_sql =
            "[EMAIL PROTECTED]@reflection.options[:as]}_id
= [EMAIL PROTECTED] AND " +
            "[EMAIL PROTECTED]@reflection.options[:as]}_type
= [EMAIL PROTECTED](@owner.class.base_class.name.to_s)}"
        else
          @finder_sql =
"[EMAIL PROTECTED]@reflection.primary_key_name} =
[EMAIL PROTECTED]"
        end
        @finder_sql << " AND (#{conditions})" if conditions
      end

This cannot easily be changed. The type condition should be a function
call so we could easily modified. Has anybody thought about this?
-- 
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 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