i have 3 models (student
, document
, , cv
). document
has single table inheritance. question how create cv off of @student
? i've tried @student.documents.new(type: cv)
gives me:
error
nomethoderror: undefined method `safe_constantize' #<class:0x007fd1819adad0>
i know can cv.new(owner: @student)
doesn't feel elegant.
models
class student < activerecord::base has_many :documents, as: :owner end class document < activerecord::base has_many :documents, as: :owner end class cv < document end
your answer is:
@cv = @student.documents.build @cv.type = "cv"
Comments
Post a Comment