Permalink
Browse files

-model TranslatesLanguages +models: UsersLanguage, Skill, Native

  • Loading branch information...
1 parent b35094f commit 0451c5bf195bce6228b5427fb472dcfad54d933e @DarTSeNSe committed Dec 9, 2011
View
@@ -1,8 +1,10 @@
class Language < ActiveRecord::Base
+
attr_accessible :language
+ belongs_to :users_languages
+ belongs_to :phrase
belongs_to :translate
- belongs_to :translates_languages, :dependent => :destroy
validates :language, :presence => true,
View
@@ -0,0 +1,9 @@
+class Native < ActiveRecord::Base
+
+ attr_accessible :nativelang
+
+ belongs_to :user
+
+ validates :nativelang, :presence => true
+
+end
View
@@ -1,16 +1,19 @@
class Phrase < ActiveRecord::Base
+
attr_accessible :phrase, :tag
has_many :translates, :dependent => :destroy
has_many :translates_phrases, :class_name => "TranslatesPhrases",
:foreign_key => "translate_id",
:dependent => :destroy
-
+ has_one :language
belongs_to :user
validates :phrase, :presence => true,
:length => { :maximum => 140 },
:uniqueness => { :case_sensitive => false }
+ validates :tag, :presence => true,
+ :length => { :maximum => 16 }
validates :user_id, :presence => true
-
+ validates :language_id, :presence => true
end
View
@@ -0,0 +1,9 @@
+class Skill < ActiveRecord::Base
+
+ attr_accessible :skill
+
+ belongs_to :users_languages
+
+ validates :skill, :presence => true
+
+end
View
@@ -4,6 +4,8 @@ class Translate < ActiveRecord::Base
belongs_to :phrase
belongs_to :translates_phrases, :foreign_key => "phrase_id",
:dependent => :destroy
+ has_one :language
+
validates :translate, :presence => true,
:length => { :maximum => 200 },
@@ -1,11 +0,0 @@
-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
@@ -5,7 +5,4 @@ class TranslatesPhrases < ActiveRecord::Base
belongs_to :phrase
belongs_to :translate
- validates :phrase_id, :presence => true
- validates :translate_id, :presence => true
-
end
View
@@ -1,8 +1,12 @@
class User < ActiveRecord::Base
+
attr_accessor :password
attr_accessible :name, :email, :password, :password_confirmation
has_many :phrases, :dependent => :destroy
+ has_many :users_languages, :class_name => "UsersLanguages",
+ :dependent => :destroy
+ has_one :native
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
@@ -0,0 +1,9 @@
+class UsersLanguages < ActiveRecord::Base
+
+ attr_accessible :skill_id, :language_id, :user_id
+
+ belongs_to :user
+ has_many :languages
+ has_many :skills
+
+end
@@ -4,11 +4,13 @@ def change
t.string :phrase, :unique => true
t.string :tag
t.integer :user_id
+ t.integer :language_id
t.timestamps
end
add_index :phrases, :phrase
add_index :phrases, :tag
add_index :phrases, :user_id
+ add_index :phrases, :language_id
end
end
@@ -11,6 +11,5 @@ def change
add_index :translates, :translate
add_index :translates, :phrase_id
add_index :translates, :language_id
- add_index :translates, :rating
end
end
@@ -1,13 +0,0 @@
-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
@@ -0,0 +1,14 @@
+class CreateUsersLanguages < ActiveRecord::Migration
+ def change
+ create_table :users_languages do |t|
+ t.integer :user_id
+ t.integer :language_id
+ t.integer :skill_id
+
+ t.timestamps
+ end
+ add_index :users_languages, :user_id
+ add_index :users_languages, :language_id
+ add_index :users_languages, :skill_id
+ end
+end
@@ -0,0 +1,9 @@
+class CreateSkills < ActiveRecord::Migration
+ def change
+ create_table :skills do |t|
+ t.string :skill
+
+ t.timestamps
+ end
+ end
+end
@@ -0,0 +1,10 @@
+class CreateNatives < ActiveRecord::Migration
+ def change
+ create_table :natives do |t|
+ t.string :nativelang
+ t.integer :user_id
+
+ t.timestamps
+ end
+ end
+end
View
@@ -11,14 +11,21 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111209144304) do
+ActiveRecord::Schema.define(:version => 20111209221616) do
create_table "languages", :force => true do |t|
t.string "language"
t.datetime "created_at"
t.datetime "updated_at"
end
+ create_table "natives", :force => true do |t|
+ t.string "nativelang"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "phrases", :force => true do |t|
t.string "phrase"
t.string "tag"
@@ -27,33 +34,41 @@
t.datetime "updated_at"
end
- create_table "translates", :force => true do |t|
- t.string "translate"
- t.integer "phrase_id"
- t.integer "language_id"
- t.string "rating"
+ add_index "phrases", ["phrase"], :name => "index_phrases_on_phrase"
+ add_index "phrases", ["tag"], :name => "index_phrases_on_tag"
+ add_index "phrases", ["user_id"], :name => "index_phrases_on_user_id"
+
+ create_table "skills", :force => true do |t|
+ t.string "skill"
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "translates_languages", :id => false, :force => true do |t|
+ create_table "translates", :force => true do |t|
+ t.string "translate"
+ t.integer "phrase_id"
t.integer "language_id"
- t.integer "translate_id"
+ t.string "rating"
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"
+ add_index "translates", ["language_id"], :name => "index_translates_on_language_id"
+ add_index "translates", ["phrase_id"], :name => "index_translates_on_phrase_id"
+ add_index "translates", ["rating"], :name => "index_translates_on_rating"
+ add_index "translates", ["translate"], :name => "index_translates_on_translate"
create_table "translates_phrases", :id => false, :force => true do |t|
- t.integer "translate_id"
t.integer "phrase_id"
+ t.integer "translate_id"
t.datetime "created_at"
t.datetime "updated_at"
end
+ add_index "translates_phrases", ["phrase_id", "translate_id"], :name => "index_translates_phrases_on_phrase_id_and_translate_id", :unique => true
+ add_index "translates_phrases", ["phrase_id"], :name => "index_translates_phrases_on_phrase_id"
+ add_index "translates_phrases", ["translate_id"], :name => "index_translates_phrases_on_translate_id"
+
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
@@ -66,4 +81,16 @@
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
+ create_table "users_languages", :force => true do |t|
+ t.integer "user_id"
+ t.integer "language_id"
+ t.integer "skill_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "users_languages", ["language_id"], :name => "index_users_languages_on_language_id"
+ add_index "users_languages", ["skill_id"], :name => "index_users_languages_on_skill_id"
+ add_index "users_languages", ["user_id"], :name => "index_users_languages_on_user_id"
+
end

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
@@ -1,7 +1,7 @@
---
logo.png: logo-e4b51606cd77fda2615e7439907bfc92.png
application.js: application-fd525bbd17efb79c1bb774c528fe1959.js
-application.css: application-54cccbed603e6613cb16b1ebbe0e73b7.css
+application.css: application-958c188ace0226f4091a4ad03a305a99.css
blueprint/plugins/buttons/icons/cross.png: blueprint/plugins/buttons/icons/cross-1f87fac86c438386527b5e7d5ceecb0e.png
blueprint/plugins/buttons/icons/key.png: blueprint/plugins/buttons/icons/key-5f38d0204e83d3d83585a62ff993342b.png
blueprint/plugins/buttons/icons/tick.png: blueprint/plugins/buttons/icons/tick-09de3f730b3b6ef960450a506b0916a9.png
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Native do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Skill do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe UsersLanguages do
+ pending "add some examples to (or delete) #{__FILE__}"
+end

0 comments on commit 0451c5b

Please sign in to comment.