ruby - Rails 4.0.0 errors in controller: ActiveRecord::SubclassNotFound -


hi got error in controller:

activerecord::subclassnotfound in coursescontroller#create_course invalid single-table inheritance type: coursetemplate not subclass of course 

the error occurs in line:

course = course.new(self.attributes) 

what can fix ?

i've allready tried in model:

self.inheritance_column = :_type_disabled 

but got error:

mysql2::error: duplicate entry '4' key 'primary': insert `course_objects` 

this error appears becaus id of course_object tried use again, id pk

you have remove id old object attributes:

obj_attributes = self.attributes obj_attributes.delete("id")  course = course.new(obj_attributes) 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -