Skip to content

Commit 335e5b5

Browse files
committed
add seed_fu
add User/Eventモデルのダミーデータ追加
1 parent 48a14e9 commit 335e5b5

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ group :development, :test do
5050

5151
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
5252
gem 'spring'
53+
54+
gem 'seed-fu', '~> 2.3.5'
5355
end
5456

5557
group :development do

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ GEM
152152
sdoc (0.4.1)
153153
json (~> 1.7, >= 1.7.7)
154154
rdoc (~> 4.0)
155+
seed-fu (2.3.5)
156+
activerecord (>= 3.1, < 4.3)
157+
activesupport (>= 3.1, < 4.3)
155158
simple_form (3.1.0)
156159
actionpack (~> 4.0)
157160
activemodel (~> 4.0)
@@ -199,6 +202,7 @@ DEPENDENCIES
199202
rails_12factor
200203
sass-rails (~> 5.0)
201204
sdoc (~> 0.4.0)
205+
seed-fu (~> 2.3.5)
202206
simple_form
203207
spring
204208
sqlite3
123 KB
Loading

db/fixtures/csv/events.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
owner_id,name,place,start_time,end_time,content,image_file_name
2+
1,1,オバフェス,飯田橋,2015-09-12 16:30,2015-09-12 20:00,飯田橋へGo!!,app/assets/images/dummy/pictures/image001.png

db/fixtures/events.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'csv'
2+
3+
csv = CSV.read('db/fixtures/csv/events.csv')
4+
csv.each_with_index do |row, i|
5+
next if i.zero?
6+
Event.seed do |s|
7+
s.id = i
8+
s.owner_id = row[1]
9+
s.name = row[2]
10+
s.place = row[3]
11+
s.start_time= row[4]
12+
s.end_time = row[5]
13+
s.content = row[6]
14+
s.image = Rails.root.join(row[7]).open if row[7].present?
15+
s.created_at = Date.today - (i % 20)
16+
end
17+
end

db/fixtures/users.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
User.seed do |s|
2+
s.id = 1
3+
s.email = "obana@obanaction.com"
4+
s.encrypted_password = "obanaction"
5+
s.created_at = Date.today - (1 % 20)
6+
s.last_sign_in_at = Date.yesterday
7+
end

0 commit comments

Comments
 (0)