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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:28:07+00:00 2026-06-01T15:28:07+00:00

FactoryGirl.define do sequence :email do |n| user#{n}@example.com end factory :user do email {FactoryGirl.generate :email}

  • 0
FactoryGirl.define do
  sequence :email do |n|
    "user#{n}@example.com"
  end

  factory :user do
    email {FactoryGirl.generate :email}
    password "abc"
    admin false
  end
end

works just fine but if I do

FactoryGirl.define do
  sequence :email {|n| "user#{n}@example.com"}

  factory :user do
    email {FactoryGirl.generate :email}
    password "abc"
    admin false
  end
end

I get the following error

/Users/brad/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activesupport-3.0.10/lib/active_support/dependencies.rb:235:in `load': /Users/brad/Ruby_Rails/acute_pain/spec/factories.rb:2: syntax error, unexpected '{', expecting keyword_end (SyntaxError)
  sequence :email {|n| "user#{n}@example.com"}
                   ^

Whaaaaa?

I’m using Factory Girl 3.1.0 and Rails 3.0.10.

  • 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-01T15:28:08+00:00Added an answer on June 1, 2026 at 3:28 pm

    Be careful with the parameters! 🙂

    sequence(:email) {|n| "user#{n}@example.com"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ruby-1.9.2-p180 :007 > Factory.define :user do |user| ruby-1.9.2-p180 :008 > user.email user@example.com ruby-1.9.2-p180 :009?>
Here are my factories: FactoryGirl.define do factory :account do company 'Example, Inc.' end factory
I have the following factories: Factory.define :producer, :class => User do |f| f.sequence(:email) {
When building the following factory: Factory.define :user do |f| f.sequence(:name) { |n| foo#{n} }
FactoryGirl won't set my protected attribute user.confirmed . What's the best practice here? Factory.define
I have some factorygirl factories that involve associations to other factories. For example: FactoryGirl.define
Situation # Models class User < ActiveRecord::Base has_many :items end class Items < ActiveRecord::Base
What I have now: class User < ActiveRecord::Base has_many :people end ... and... class
i'm using Rspec and factory girl to set my tests. I have a user
Using the FactoryGirl gem, inside the factories.rb file, how can I create a factory

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.