Alain Ravet
2006-Jan-10 16:55 UTC
[Rails] bug? : STI and :include => fk and class_name MUST be specified
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?
Reasonably Related Threads
- how to use scope with acts_as_list
- create 2 fk referencing the same table
- How to manage the form of a model that has two foreign keys
- Does :class_name for belongs_to have to be a string and why?
- Problem saving parent and children using belongs_to, class_name, and foreign_key