title: Factory-bot - How to build association and nested attributes
body: <p>I am new to Factories and I need help for the association and nested attributes....</p>
  
  <ul>
  <li>How do I set an admin user that creates a product?  OK</li>
  <li>How do I set category to a product?   Ok</li>
  <li><p>How do I attach images to a product? OK </p></li>
  <li><p>How do I set product's sizes (nested attibutes)</p></li>
  </ul>
  
  <p>user.rb </p>
  
  <pre><code> has_many :products
  </code></pre>
  
  <p>product.rb </p>
  
  <pre><code>belongs_to :user
  belongs_to :category
  has_many :sizes, inverse_of: :product, dependent: :destroy #nested_attributes 
  </code></pre>
  
  <p>size.rb </p>
  
  <pre><code>belongs_to :product
  </code></pre>
  
  <p>category.rb </p>
  
  <pre><code>has_many :products
  </code></pre>
  
  <p>factories/users.rb </p>
  
  <pre><code>  FactoryBot.define do
      factory :user do 
          first_name        { Faker::Name.first_name}
          last_name         { Faker::Name.last_name }
          admin             { [false, true].sample }
          sequence(:email)  { |n| "#{n}#{Faker::Internet.email}" }
          birth_date        {"20/10/1997"}
          password          { 'password'}
      end 
    end
  </code></pre>
  
  <p>factories/categories.rb</p>
  
  <pre><code>FactoryBot.define do
    factory :category do
      title { Faker::Artist.name }
    end
  end
  </code></pre>
  
  <p>factories/sizes.rb </p>
  
  <pre><code>FactoryBot.define do 
      factory :size do 
          size_name {["S", "M", "L", "XL"].sample }
          quantity  { Faker::Number.number(2) }
      end
  end
  </code></pre>
  
  <p>factories/products.rb </p>
  
  <pre><code>FactoryBot.define do
    factory :product do
      title { Faker::Artist.name}
      ref   { Faker::Number.number(10)}
      price { Faker::Number.number(2) }
      color { Faker::Color.color_name }
      brand { Faker::TvShows::BreakingBad }
      description { Faker::Lorem.sentence(3) }
      size
      category
      # how to set an admin ?? 
    end
  end
  </code></pre>