mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 10:38:50 +01:00
Create Problem model with reference to current translation
This commit is contained in:
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.
|
# 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|
|
create_table "translations", force: true do |t|
|
||||||
t.string "title"
|
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
|
||||||
Reference in New Issue
Block a user