Advertisement
Guest User

Untitled

a guest
Jan 24th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.41 KB | None | 0 0
  1. class Product < ActiveRecord::Base
  2.   attr_accessible :name, :category_id
  3.   validates :category, presence: true
  4.   belongs_to :category
  5. end
  6.  
  7. class Category < ActiveRecord::Base
  8.   attr_accessible :name
  9.   has_many :products
  10. end
  11.  
  12. FactoryGirl.define do
  13.   factory :category do
  14.     name "MyString"
  15.   end
  16. end
  17.  
  18. FactoryGirl.define do
  19.   factory :product do |f|
  20.     name "MyString"
  21.     category
  22.   end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement