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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:24:43+00:00 2026-05-18T07:24:43+00:00

Trying to make a simple application in rails 3. If I create a team

  • 0

Trying to make a simple application in rails 3.

If I create a team model with rails g scaffold team name:string && rake db:migrate, then run rake, I get success from the prebuilt tests.

If I simply add validates_uniqueness_of :name to the team model. The functional tests fail with

  1) Failure:
test_should_create_team(TeamsControllerTest) [/test/functional/teams_controller_test.rb:20]:
"Team.count" didn't change by 1.
<3> expected but was
<2>.

I modified tests/fixtures/teams.yml to look like this:

one:
    name: MyString
two:
    name: MyString2

The test still fails.

It can’t get much more basic than this; what have I missed?

  • 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-05-18T07:24:44+00:00Added an answer on May 18, 2026 at 7:24 am

    Fixtures basically represent model instances that are in the database.

    If you look at the top of test/functional/teams_controller_test.rb you’ll see

    setup do
      @team = teams(:one)
    end
    

    and then in your failing functional test you’ll have

    post :create, :team => @team.attributes
    

    This is what’s happening: you’re trying to create a new team with the same attributes as “the team fixture named :one”. Since both would have the same name (since they have the exact same attributes), the uniqueness validation is failing.

    Try replacing your setup block with this

    setup do
      @team = teams(:one)
      @team.name = 'unique name'
    end
    

    Now you’ll be creating a new team with the name ‘unique name’ (which isn’t in the database according to the fixtures), and your test will pass.

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

Sidebar

Related Questions

I'm trying to make a simple blackjack program. Sadly, I'm having problems right off
I'm trying to make a simple C# web server that, at this stage, you
I'm trying to make things simpler. Here is my code: If Threading.Monitor.TryEnter(syncRoot) Then Try
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to make a make generic select control that I can dynamically add elements
Trying to make a generic PL/SQL procedure to export data in specific XML format,
Trying to make a web service call to an HTTPS endpoint in my Silverlight
I'm trying to make the case for click-once and smart client development but my
I'm trying to make a data bound column invisible after data binding, because it
I'm trying to make a context menu for a control that is linked to

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.