Generated model Answer with migration
This commit is contained in:
3
app/models/answer.rb
Normal file
3
app/models/answer.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Answer < ActiveRecord::Base
|
||||
belongs_to :question
|
||||
end
|
||||
10
db/migrate/20140227235843_create_answers.rb
Normal file
10
db/migrate/20140227235843_create_answers.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateAnswers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :answers do |t|
|
||||
t.text :response
|
||||
t.references :question, index: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
9
test/fixtures/answers.yml
vendored
Normal file
9
test/fixtures/answers.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
response: MyText
|
||||
question_id:
|
||||
|
||||
two:
|
||||
response: MyText
|
||||
question_id:
|
||||
7
test/models/answer_test.rb
Normal file
7
test/models/answer_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AnswerTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user