SHOW:
|
|
- or go back to the newest paste.
1 | # seeds.rb: | |
2 | - | ... |
2 | + | 30.times { |
3 | user = User.create!(name: Faker::Internet.user_name, email: Faker::Internet.email, password: 'password') | |
4 | project = Project.create!(name: Faker::Company.name, description: Faker::HipsterIpsum.words.join(' ')).users << user | |
5 | Post.create!(title: Faker::HipsterIpsum.word, text: Faker::DizzleIpsum.words(100).join(' '), user: user, project: project) | |
6 | ||
7 | } | |
8 | ||
9 | class User | |
10 | belongs_to :project | |
11 | belongs_to :section | |
12 | has_many :posts | |
13 | end | |
14 | ||
15 | class Section | |
16 | has_many :users | |
17 | has_many :posts | |
18 | has_many :projects | |
19 | end | |
20 | ||
21 | class Project | |
22 | has_many :users | |
23 | has_many :posts | |
24 | belongs_to :section | |
25 | end | |
26 | ||
27 | class Post | |
28 | belongs_to :project | |
29 | belongs_to :user | |
30 | belongs_to :section | |
31 | end |