1
0
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:
Philipp Fischbeck 2014-12-14 23:11:40 +01:00
parent e13b82ad1f
commit 79ed82cfd8
6 changed files with 38 additions and 1 deletions

3
app/models/problem.rb Normal file
View File

@ -0,0 +1,3 @@
class Problem < ActiveRecord::Base
has_one :translation
end

View File

@ -0,0 +1,7 @@
class CreateProblemsAgain < ActiveRecord::Migration
def change
create_table :problems do |t|
t.timestamps
end
end
end

View File

@ -0,0 +1,5 @@
class AddTranslationToProblem < ActiveRecord::Migration
def change
add_reference :problems, :translation, index: true
end
end

View File

@ -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
View File

@ -0,0 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
Translation_id:
two:
Translation_id:

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ProblemTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end