Forum: Ruby on Rails bug? : STI and :include => fk and class_name MUST be specifi

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0091f92762685860109bbcb02edfdf27?d=identicon&s=25 Alain Ravet (Guest)
on 2006-01-10 17:56
(Received via mailing list)
I suspect this is a bug. Or a limitation.

Problem:
----------------
When you include a STI class in a 'find' :
        @results = Result.find :all, :include => :event

, you are forced to specify the fk and the class name :
         belongs_to  :event , :class_name => "Event", :foreign_key =>
"event_id"
.


Full code:
-----------

class Event < Foo   ### <<---- S.T.I.
     has_many    :results
end

class Result < ActiveRecord::Base
     belongs_to  :event ,
             :class_name => "Event", :foreign_key => "event_id"  ###
MANDATORY ?!

     acts_as_list
end

Alain

Q: If this is a unknown bug, do I have to report it officially?
This topic is locked and can not be replied to.