title: rails: rake populating data
body: <p>I have a lot of users who has tags, and a lot of posts which has tags.</p>
  
  <p>I want to autopopulate my database when I run rake db:populate. This is my code under lib/tasks:</p>
  
  <pre><code>def make_tags
     User.all.each do |user|
        5.times do |n|
          name = Faker::Company.bs
          user.tags.create!(:name =&gt; name)
        end
  
      end  
     Micropost.all.each do |micropost|
        3.times do |n|
          name = Faker::Company.bs
          micropost.tags.create!(:name =&gt; name)
        end
     end  
  </code></pre>
  
  <p>However the problem is that usesrs and posts do not share the same tags, because a new tag is created each time. Is there a way to reference to previously created tags by their ids and so that I do not create new tags everytime?</p>