I had a tough time getting ActiveScaffold to work with STI. As per the development roadmap for AS, this will be available only in version 1.3! Since I desperately needed this to work, I figured out a quick workaround. In the models, rename your foreign keys to the name of the derived class. That’s it! Below is an example.
# Base class
class Promotion < ActiveRecord::Base
end
# Derived class
class SurveyPromotion < Promotion
has_many :surveys,
:foreign_key => 'survey_promotion_id'
end
# Associated class
class Survey < ActiveRecord::Base
belongs_to :survey_promotion,
:foreign_key => 'survey_promotion_id'
end
I too was struggling with the same issue, but it’s dependent upon Type column as rails STI, which is a protected column and I wasn’t able to set/update this attribute.
Solution:
Create/Update and EMBEDDING :
* constraints are now applied to a record during the #new action, in case any custom form rendering depends on the constrained column
So i just rendered my action based on :constraints => { :type => ‘parent_model’} and it worked and its a very good fix by AS.
Thanks,
Akshay