Skip to content

Commit

Permalink
FactoryGirlデータをつくる
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshifumi0521 committed Sep 19, 2012
1 parent 4257aac commit 669deae
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 2 deletions.
Binary file added app/models/.article.rb.swp
Binary file not shown.
4 changes: 3 additions & 1 deletion app/models/article.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#coding: utf-8
class Article < ActiveRecord::Base
validates_presence_of :title

#belongs_toでUserモデルと1対服すの関係をつくる。
belongs_to :user


end
6 changes: 6 additions & 0 deletions app/models/article.rb~
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Article < ActiveRecord::Base
validates_presence_of :title



end
9 changes: 9 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#coding: utf-8
class User < ActiveRecord::Base
has_many :articles





end
1 change: 1 addition & 0 deletions db/migrate/20120913082957_create_articles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ def change
t.string :title
t.text :body


t.timestamps
end
end
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20120919122945_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|

t.timestamps
end
end
end
7 changes: 6 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120913082957) do
ActiveRecord::Schema.define(:version => 20120919122945) do

create_table "articles", :force => true do |t|
t.string "title"
Expand All @@ -20,4 +20,9 @@
t.datetime "updated_at", :null => false
end

create_table "users", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

end
Binary file modified spec/.DS_Store
Binary file not shown.
Binary file added spec/factories/.DS_Store
Binary file not shown.
25 changes: 25 additions & 0 deletions spec/factories/articles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#coding: utf-8
# Read about factories at https://github.com/thoughtbot/factory_girl

#FactoryGirlのデータを定義する。
FactoryGirl.define do
factory :article do
title "初めてのブログ"
body "ブログはじめました"

end
end














10 changes: 10 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#coding: utf-8
# Read about factories at https://github.com/thoughtbot/factory_girl

FactoryGirl.define do
factory :user do



end
end
5 changes: 5 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe User do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 669deae

Please sign in to comment.