Oooookay...this might be a bit over the top, but it might hint at another problem more relevant.
In general you use Mixins to share common functionality in Ruby/Ruby on Rails. In several of my recent projects I choose abstract superclasses, instead; at the same time I used polymorphism. I.e.
class Parent < ActiveRecord::Base
self.abstract_class = true
has_one :xxx, :as => :poly_xxx
has_many :documents, :through => :xxx, :readonly => false
[more shared document handling stuff]
end
class Xxx < ActiveRecord::Base
belongs_to :special_xxx, :polymorphic => true
[...]
end
class Document < ActiveRecord::Base
belongs_to :xxx
[...]
end
class ChildA < Parent
[special stuff A]
end
class ChildB < Parent
So far there had been no problems nesting the documents into ClassA and ClassB etc.:
class ChildBsController < ApplicationController
active_scaffold :child_b do |conf|
[...]
conf.nested.add_link(:documents)
end
[...]
end
Everything worked like a charm, I could freely list, created and update the attached documents via the nested action link.
All of a sudden it stopped working; alas, because this was in a non-tested part (*BLUSH*), I can't pin it down to any specific recent update. Doing some debugging, though, I was able to localize it somewhere in the vicinity of the abstract base_class, because the parameter hash contained a hash key parent_id, where it so far contained the hash key child_b_id.
As I was not able to locate the trouble spot. I switched to using a Mixin instead of the abstract base_class, and everything is working fine again.
Nevertheless, this seems to hint at an AS problem with finding the reverse association under the described –not so common– circumstances.
Regards
Michael