I have BaseProject
, ProjectTemplate
and Project
class ProjectTemplate << BaseProject; end
class Project << BaseProject; end
I would like to copy project_template attributes to a new project instance as defaults.
The problem is if i use dup
project will have type
set to ProjectTemplate
project_template = ProjectTemplate.first
project = project_template.dup
i can set the type by hand
project.type = "Project"
but i don't like it that way, or i can do this
project_template = ProjectTemplate.first
project = Project.new( project_template.attributes.except("id", "type") )
but i read this question which recommends against the second solution.
What whould be the recommended way to solve this issue?