在这里,您可以编写一个迁移,在创建问题时添加默认问题,
class ChangeDefaultQuestions < ActiveRecord::Migration
def self.up
change_column :questions, :question_one, :string, :default => 'What is your name?'
change_column :questions, :question_two, :string, :default => 'How old are you?'
change_column :questions, :question_three, :string, :default => 'Where do you live'
# to add default questions to previously created questions
Questions.update_all({ :question_one => 'your qestion', :question_two => 'your question', :question_three => 'your question' })
end
def self.down
change_column :movies, :rating, :string, :default => nil
Questions.update_all({ :question_one => '', :question_two => '', :question_three => '' })
end
end
我相信它会回答你的问题