Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:11:54+00:00 2026-06-06T01:11:54+00:00

I have an interesting scenario. I have a task model which has a task

  • 0

I have an interesting scenario.

I have a task model which has a task status:

class Task < ActiveRecord::Base
 belongs_to :task_status
end

class TaskStatus < ActiveRecord::Base
 has_many :tasks
end

I define factories for both of those models for my testing:

FactoryGirl.define do
  factory :task do
    title  'sample task'
    task_status { |task| task.association(:actvice_status) }
  end
end

FactoryGirl.define do
  factory :active_status do
    status_value "ACTIVE"
  end
end

The problem comes when creating instances for testing:

10.times do
  task = FactoryGirl.create(:task)
end

This will create 10 tasks and also 10 “ACTIVE” task statuses. In reality, I need just 1 task status, which the task can reference. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:11:55+00:00Added an answer on June 6, 2026 at 1:11 am

    The easiest thing:

    active = create(:active_status)
    tasks = []
    10.times do
        tasks << create(:task, task_status: active)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came across an interesting scenario. I have a class in C#: public
I'm using SQL Server 2008. I have an interesting scenario where a stored procedure
I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
I have an interesting problem to solve. One of my clients has me developing
I have very interesting scenario: I've specified two controllers, one for global events and
I have an interesting scenario and the answer isn't jumping out at me. I've
I have ran into quite an interesting mapping scenario. I have two entities (
We have an interesting scenario I need to sort out: 1) We have an
I have an interesting scenario that I need assistance with. I have a classic
I have the following interesting scenario: I've install ruby 1.9.2 via RVM and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.