Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+models: Language,TranslatesLanguages

  • Loading branch information...
commit b35094fe25011f1e271641bde0d8607bb23d1be5 1 parent 61a29db
@DarTSeNSe authored
View
9 app/models/language.rb
@@ -0,0 +1,9 @@
+class Language < ActiveRecord::Base
+ attr_accessible :language
+
+ belongs_to :translate
+ belongs_to :translates_languages, :dependent => :destroy
+
+ validates :language, :presence => true,
+
+end
View
11 app/models/translates_languages.rb
@@ -0,0 +1,11 @@
+class TranslatesLanguages < ActiveRecord::Base
+
+ attr_accessible :language_id
+
+ belongs_to :language
+ belongs_to :translate
+
+ validates :language_id, :presence => true
+ validates :translate_id, :presence => true
+
+end
View
3  app/models/translates_phrases.rb
@@ -1,5 +1,6 @@
class TranslatesPhrases < ActiveRecord::Base
- attr_accessible :translate_id, :phrase_id
+
+ attr_accessible :translate_id
belongs_to :phrase
belongs_to :translate
View
9 db/migrate/20111209143856_create_languages.rb
@@ -0,0 +1,9 @@
+class CreateLanguages < ActiveRecord::Migration
+ def change
+ create_table :languages do |t|
+ t.string :language
+
+ t.timestamps
+ end
+ end
+end
View
13 db/migrate/20111209144304_create_translates_languages.rb
@@ -0,0 +1,13 @@
+class CreateTranslatesLanguages < ActiveRecord::Migration
+ def change
+ create_table :translates_languages, :id => false do |t|
+ t.integer :language_id
+ t.integer :translate_id
+
+ t.timestamps
+ end
+ add_index :translates_languages, :language_id
+ add_index :translates_languages, :translate_id
+ add_index :translates_languages, [:language_id, :translate_id], :unique => true
+ end
+end
View
21 db/schema.rb
@@ -11,7 +11,13 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111209124823) do
+ActiveRecord::Schema.define(:version => 20111209144304) do
+
+ create_table "languages", :force => true do |t|
+ t.string "language"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
create_table "phrases", :force => true do |t|
t.string "phrase"
@@ -30,9 +36,20 @@
t.datetime "updated_at"
end
+ create_table "translates_languages", :id => false, :force => true do |t|
+ t.integer "language_id"
+ t.integer "translate_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "translates_languages", ["language_id", "translate_id"], :name => "index_translates_languages_on_language_id_and_translate_id", :unique => true
+ add_index "translates_languages", ["language_id"], :name => "index_translates_languages_on_language_id"
+ add_index "translates_languages", ["translate_id"], :name => "index_translates_languages_on_translate_id"
+
create_table "translates_phrases", :id => false, :force => true do |t|
- t.integer "phrase_id"
t.integer "translate_id"
+ t.integer "phrase_id"
t.datetime "created_at"
t.datetime "updated_at"
end
View
5 spec/models/language_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Language do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
5 spec/models/translates_languages_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe TranslatesLanguages do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.