View difference between Paste ID: FRUh1iLU and Yi6gMVN5
SHOW: | | - or go back to the newest paste.
1
# seeds.rb:
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
# Models: 
10
class User
11
  belongs_to :project
12
  belongs_to :section
13
  has_many   :posts
14
end
15
16
class Section
17
  has_many :users
18
  has_many :posts
19
  has_many :projects
20
end
21
22
class Project
23
  has_many  :users
24
  has_many  :posts
25
  belongs_to :section
26
end
27
28
class Post
29
  belongs_to :project
30
  belongs_to :user
31
  belongs_to :section
32
end