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 9265285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:01:53+00:00 2026-06-18T14:01:53+00:00

I have a FactoryGirl factory defining some default values for an ActiveRecord::Base class. All

  • 0

I have a FactoryGirl factory defining some default values for an ActiveRecord::Base class. All of the values except one are making it to the instantiated class except for one.

Here is my factory:

FactoryGirl.define do
  factory :office, :class => Office do
    open_date '03/01/2011'
    set_up_date '04/28/2011'
    type_code 'D'
  end

  after(:build) do |office|
    puts "Office open_date: #{office.open_date}"
    puts "Office set_up_date: #{office.set_up_date}"
  end
end

Here is my base class:

class Office < ActiveRecord::Base
end

When I do FactoryGirl.build :office, I get the following output:

Office open_date: 2011-01-03 00:00:00 -0500
Office set_up_date:

Both columns are DATE datatypes on the database. For some reason, only open_date is getting populated on the base class. I have not, so far, been able to determine why. Since I am only calling build, I think I can safely assume that there is no kind of interference from a database trigger.

Any ideas what would cause set_up_date to not get populated on the class instance?

Versions:

activemodel (3.2.11)
activerecord (3.2.11)
activerecord-oracle_enhanced-adapter (1.4.1)
activesupport (3.2.11)
factory_girl (4.2.0)

JRuby 1.7.2 (Running Ruby in 1.9 mode)

Thanks

  • 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-18T14:01:55+00:00Added an answer on June 18, 2026 at 2:01 pm

    Just out of curiousity, would your try set_up_date '28/04/2011' instead of 04/28/2011? It looks like FactoryGirl understands your input as DD/MM/YYYY according to:

    Office open_date: 2011-01-03 00:00:00 -0500
    

    See 01-03 not 03-01 there?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this factory: FactoryGirl.define do factory :from_sector, class: Sector do sequence(:name) { |n|
I have the following models class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable,
I have the following setup: Models: class Product < ActiveRecord::Base has_one :product_category attr_accessible :name,
In my models I have the following setup: class User < ActiveRecord::Base has_many :assignments
I have a model Answer: class Answer < ActiveRecord::Base attr_accessible :content belongs_to :question end
I have a factory like that: FactoryGirl.define do factory :member_data, :class => Member do
I have the following in /app/models: class Area < ActiveRecord::Base has_many :locations end class
I have a Factory like this: FactoryGirl.define do factory :subject do name 'Calculus' end
I have this example FactoryGirl.define do @site = FactoryGirl.create(:my_site) factory :user do email {
I have a simple user factory that looks like this: FactoryGirl.define do factory :user

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.