0
class Question < ActiveRecord::Base
has_many :tasks, :as => :task
end
class QuestionPlayer < Question
end
class QuestionGame < Question
end
class Tast < ActiveRecord::Base
belongs_to :task, :polymorphic => true
end
當我做
Task.create :task => QuestionPlayer.new
#<Task id: 81, ... task_id: 92, task_type: "Question">
爲什麼呢?我怎樣才能得到任務與task_type =「QuestionPlayer」?
謝謝,馬林!它工作正常!很好,謝謝你對這個問題的解釋 – wolfer