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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:44:20+00:00 2026-05-28T03:44:20+00:00

I have the following task: namespace :db do desc Drop, create, migrate, seed the

  • 0

I have the following task:

namespace :db do
  desc "Drop, create, migrate, seed the database and prepare the test database for rspec"
  task :reset_db => :environment do
    puts "Environment Check: Rails Environment = #{Rails.env}"
    Rake::Task['db:drop'].invoke
    Rake::Task['db:create'].invoke
    Rake::Task['db:migrate'].invoke
    #Rake::Task['db:fixtures:load'].invoke
    Rake::Task['db:test:prepare'].invoke
    puts 'Seeding Database..'
    Rake::Task['db:seed'].invoke
  end
end

This task works fine up to the last db:seed line.
It seems to be using the test environment and creates the data there, while all the other tasks execute in the development environment. When I execute rake db:seed via the command line, it runs correctly in the development environment.

How can I prevent it from running in the test environment?

  • 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-28T03:44:20+00:00Added an answer on May 28, 2026 at 3:44 am

    The db:test:prepare rake task prepares the test database, and therefore sets RAILS_ENV=test.

    So the reason why your task gets run in the testing environment is because db:test:prepare actually overwrites your RAILS_ENV variable.

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

Sidebar

Related Questions

I have following code in my deploy.rb namespace :app do desc copies the configuration
I have the following task: Create one website which is accessible with 20 different
I have the following task task testGeb(type:Test) { jvmArgs '-Dgeb.driver=firefox' include geb/**/*.class testReportDir =
I have the following task task :default => ['build_html'] desc 'Generar documentacion desde markdown'
I have the following tasks in my deploy.rb namespace :unicorn do desc stop unicorn
I have following code to accomplish prefix sum task: #include <iostream> #include<math.h> using namespace
I have the following task, which because of the combination of DestinationFiles and DestionationFolder
I have the following task in my MSBuild script: <Target Name=ZipStates> <Message Text=CREATING ZIP
I have the following beans Task, ServerDetails and ApplicationDetails. I wish to retrieve all
I am novice in sharepoint programming. I have a following code: SPWorkflowTask task =

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.