I have a user and story models which both of them have comments.
I declared the following models as below:
class Comment
belongs_to :commentable, polymorphic: true
belongs_to :user
end
class User
end
class Story
end
Now, I want to declare a comment object with FactoryGirl that belongs to the same user as commendable and as user.
Here is my code so far:
FactoryGirl.define do
factory :user do
sequence(:email) {|n| "person#{n}@exmaple.com"}
sequence(:slug) {|n| "person#{n}"}
end
factory :comment do
occured_at { 5.hours.ago }
user
association :commentable, factory: :user
end
end
The problem here is that the user that write the comment and the commendable user are not the same.
Why should I fix that?
Many TNX