Models statt nur Migrations generiert. Damit auch die Attribute in die DB bekommen.

This commit is contained in:
gchq 2011-05-04 22:50:36 +02:00
parent 8992818890
commit 3f1c7b6190
16 changed files with 159 additions and 36 deletions

4
app/models/contact.rb Normal file
View file

@ -0,0 +1,4 @@
class Contact < ActiveRecord::Base
has_many :mails
has_many :phones
end

3
app/models/mail.rb Normal file
View file

@ -0,0 +1,3 @@
class Mail < ActiveRecord::Base
belongs_to :contact
end

3
app/models/phone.rb Normal file
View file

@ -0,0 +1,3 @@
class Phone < ActiveRecord::Base
belongs_to :contact
end

View file

@ -1,7 +0,0 @@
class CreateContacts < ActiveRecord::Migration
def self.up
end
def self.down
end
end

View file

@ -1,7 +0,0 @@
class CreateMailsForContacts < ActiveRecord::Migration
def self.up
end
def self.down
end
end

View file

@ -1,7 +0,0 @@
class CreatePhonesForContacts < ActiveRecord::Migration
def self.up
end
def self.down
end
end

View file

@ -0,0 +1,19 @@
class CreateContacts < ActiveRecord::Migration
def self.up
create_table :contacts do |t|
t.string :firstname
t.string :lastname
t.string :street
t.string :housenr
t.string :plz
t.string :place
t.string :country
t.timestamps
end
end
def self.down
drop_table :contacts
end
end

View file

@ -0,0 +1,14 @@
class CreateMails < ActiveRecord::Migration
def self.up
create_table :mails do |t|
t.string :desc
t.string :address
t.timestamps
end
end
def self.down
drop_table :mails
end
end

View file

@ -0,0 +1,14 @@
class CreatePhones < ActiveRecord::Migration
def self.up
create_table :phones do |t|
t.string :desc
t.string :nr
t.timestamps
end
end
def self.down
drop_table :phones
end
end

View file

@ -10,6 +10,32 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110502221705) do
ActiveRecord::Schema.define(:version => 20110504202804) do
create_table "contacts", :force => true do |t|
t.string "firstname"
t.string "lastname"
t.string "street"
t.string "housenr"
t.string "plz"
t.string "place"
t.string "country"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "mails", :force => true do |t|
t.string "desc"
t.string "address"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "phones", :force => true do |t|
t.string "desc"
t.string "nr"
t.datetime "created_at"
t.datetime "updated_at"
end
end

19
test/fixtures/contacts.yml vendored Normal file
View file

@ -0,0 +1,19 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
firstname: MyString
lastname: MyString
street: MyString
housenr: MyString
plz: MyString
place: MyString
country: MyString
two:
firstname: MyString
lastname: MyString
street: MyString
housenr: MyString
plz: MyString
place: MyString
country: MyString

9
test/fixtures/mails.yml vendored Normal file
View file

@ -0,0 +1,9 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
desc: MyString
address: MyString
two:
desc: MyString
address: MyString

9
test/fixtures/phones.yml vendored Normal file
View file

@ -0,0 +1,9 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
desc: MyString
nr: MyString
two:
desc: MyString
nr: MyString

View file

@ -0,0 +1,8 @@
require 'test_helper'
class ContactTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

8
test/unit/mail_test.rb Normal file
View file

@ -0,0 +1,8 @@
require 'test_helper'
class MailTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

8
test/unit/phone_test.rb Normal file
View file

@ -0,0 +1,8 @@
require 'test_helper'
class PhoneTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end