私はこのエラーをしつこくグーグルで検索しようとしましたが、役に立ちませんでした。私は現在これらのモデルを持っています
アプリ/モデル/survey.rb
class Survey < ActiveRecord::Base
belongs_to :user
has_attached_file :original, :default_url => "/public/:class/:attachment/:basename.:extension"
has_many :sub_surveys, :dependent => :destroy
end
アプリ/モデル/sub_survey.rb
class SubSurvey < ActiveRecord::Base
belongs_to :survey
has_many :questions, :dependent => :destroy
end
アプリ/モデル/質問.rb
class Question < ActiveRecord::Base
belongs_to :sub_survey
validates_presence_of :sub_survey
acts_as_list :scope => :sub_survey
#after_destroy :destroy_orphaned_choices
has_many :answers, :dependent => :destroy
has_many :choices, :dependent => :destroy
end
アプリ/モデル/choice.rb
class Choices < ActiveRecord::Base
belongs_to :question
validates_presence_of :question
end
アプリ/モデル/answer.rb
class Answer < ActiveRecord::Base
belongs_to :question
belongs_to :user
belongs_to :game
validates_uniqueness_of :question_id, :scope => [:user_id, :game_id]
end
調査を破棄しようとすると、エラーが発生するようになりました
uninitialized constant Question::Choice
これは、survey.destroy の後に /vendor/rails/active* のものをトレースします
次に、question.choices からの選択肢にアクセスしようとすると、エラーが発生します
undefined method `Choices' for #<Question:0xb7224f2c>
何らかの理由でこれが trace-stack の上にあります
vendor/rails/activerecord/lib/active_record/attribute_methods.rb:256:in `method_missing'
vendor/plugins/attribute_fu/lib/attribute_fu/associations.rb:28:in `method_missing'
app/views/answers/_answer.html.erb:7:in `_run_erb_47app47views47answers47_answer46html46erb'
調査を xml 形式でインポートするときに attribute_fu を使用しますが、question.Choices のトレースにそれがある理由がわかりません。
また、choices の名前を choicealternatives に変更しようとしましたが、効果はありませんでした。
何か案は?