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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:50:27+00:00 2026-06-18T10:50:27+00:00

Howcome when I use FactoryGirl to create a record and later update said record

  • 0

Howcome when I use FactoryGirl to create a record and later update said record the factorygirl instance isn’t updated? For example if I have the following factory and rspec test:

factory :foo do
  bar false
end

Inside of an rspec test:

foo = FactoryGirl.create(:foo)
Foo.first.update_attribute(:bar, true)
expect(foo.bar).to eq(true) #foo.bar is false and will fail

If I change foo.bar in that last line to Foo.first.bar it passes, why the variance? Is the FactoryGirl instance not directly associated to the record? Performing the test expect(foo).to eq(Foo.first) returns true so are they not the same object?

  • 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-18T10:50:29+00:00Added an answer on June 18, 2026 at 10:50 am

    I think you might have to change

    expect(foo.bar).to eq(true)
    

    to

    expect(foo.reload.bar).to eq(true)
    

    By the way, you might like to know about be_true:

    expect(foo.reload.bar).to be_true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this code to copy and instance of my class //Create the copy
How come when I use the following method, to be used to convert all
How to create a database using connector/net programming? How come the following doesn't work?
Howcome I write, for a given example, select attendee, begindate case evaluation when 1
I have a cookie that I use on my app. It looks like this:
How come whenever I have to use awakeFromNib protocol I have to put it
How come CHECK_FUNCTION_EXISTS doesn't find clock_gettime ? I use the following code in my
I try to use the following code double d; double? a = double.TryParse(3.14, out
Let's say I have the following function which should return True if valid and
I have this piece of code which i use to compare a timestamp field

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.