我需要在我的 Rails 应用程序中克隆一个模型,我正在使用amoeba
gem 来做同样的事情。
class Quiz
belongs_to :scoring
belongs_to :skill
has_many :questions, :dependent => :destroy
has_many :attempts, :dependent => :destroy
has_many :quizzes_test_profiles, :dependent => :destroy
has_many :test_profiles, :through => :quizzes_test_profiles
has_many :evaluations_evaluation_sets, as: :resource
amoeba do
enable
end
end
class EvaluationsEvaluationSet
belongs_to :test_profile
belongs_to :resource, polymorphic: true
belongs_to :evaluation_set
end
我需要克隆Quiz
模型及其所有嵌套关联。
class QuizzesController
def duplicate_survey
id = params[:id]
original_survey = Survey.find(id)
respond_to do |format|
new_survey = original_survey.amoeba_dup
new_survey.save
if new_survey
flash[:notice] = 'Survey successfully cloned.'
else
flash[:error] = 'Survey could not be cloned'
end
format.html {redirect_to :back}
end
end
end
每当我执行上述代码时,都会出现以下错误:
uninitialized constant Quiz::EvaluationsEvaluationSet
我不知道这里的错误在哪里。请告诉我如何纠正它。