ruby on rails - Is attr_accessible inherited by derived classes whe using STI? -


i've got class structure similar family of classes using sti

class root < activerecord::base    attr_accessible :root_prop end  class child < root   attr_accessible :child_prop end  class grandchild < child   attr_accessible :gc_prop end 

all properties working fine until added attr_accesible markers, know related that. appears properties giving accessible status on base classes not getting set. attr_accessible need set each class, or need somewhere else reason values not getting set?

the comment here answer. attr_accessible method work derived classes. however, when dealing associations, accessible attribute requires _id suffix

class grandchild < child   attr_accessible :associated_class_id   belongs_to :associated_class end 

is correct way mark association attr_accessible method. detail missing original question.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -