mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 08:46:41 +01:00
Create Problem model with reference to current translation
This commit is contained in:
parent
e13b82ad1f
commit
79ed82cfd8
3
app/models/problem.rb
Normal file
3
app/models/problem.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class Problem < ActiveRecord::Base
|
||||
has_one :translation
|
||||
end
|
||||
7
db/migrate/20141214214958_create_problems_again.rb
Normal file
7
db/migrate/20141214214958_create_problems_again.rb
Normal file
@ -0,0 +1,7 @@
|
||||
class CreateProblemsAgain < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :problems do |t|
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20141214220056_add_translation_to_problem.rb
Normal file
5
db/migrate/20141214220056_add_translation_to_problem.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddTranslationToProblem < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :problems, :translation, index: true
|
||||
end
|
||||
end
|
||||
10
db/schema.rb
10
db/schema.rb
@ -11,7 +11,15 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20141213151812) do
|
||||
ActiveRecord::Schema.define(version: 20141214220056) do
|
||||
|
||||
create_table "problems", force: true do |t|
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "translation_id"
|
||||
end
|
||||
|
||||
add_index "problems", ["translation_id"], name: "index_problems_on_translation_id"
|
||||
|
||||
create_table "translations", force: true do |t|
|
||||
t.string "title"
|
||||
|
||||
7
test/fixtures/problems.yml
vendored
Normal file
7
test/fixtures/problems.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
Translation_id:
|
||||
|
||||
two:
|
||||
Translation_id:
|
||||
7
test/models/problem_test.rb
Normal file
7
test/models/problem_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ProblemTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user