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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:19:01+00:00 2026-06-10T16:19:01+00:00

I have a rails application using rake db:seed too fill in some of the

  • 0

I have a rails application using rake db:seed too fill in some of the basics in my DB to start working. This works through a little infrastructure and a fixtures.rb someone else wrote to load a YAML into the DB.
What I’m trying to do is take this infrastructure and move it into my own gem so that I can use it again elsewhere, this requires me both to have some of my own gem’s models be inserted through the gem’s seed task (which I want to have run from calling db:seed or something similar in the main app) and that the main app push some of the gem’s models using it’s own seed. The second part of this I already have working, it was a simple fix in the fixtures.rb file I was given.
The things I want to do now:

  • Move fixtures.rb into the gem: I still don’t have any of the source running this in the gem. Now to do this I can probably require the file from the [MyGem::Engine.root, 'lib', ...].join then call a method there with a path to load YAML files from into the DB, which I don’t see why it shouldn’t work.
  • Get rake db:seed to run a task defined in my gem. I’ve added .rake files under lib/tasks of my gem (it’s an engine) and I can’t seem to call them from the main app rakefile though.
    To make myself clear, what I want to do is through the gem (not the main app – or with 1 line of code in the main app) add a dependency onto the main apps seed task, so that when someone runs rake db:seed in the main app the gem will run additional seeding without the main app developer even having to know about them.

The dirty solution that I want to avoid is loading the .rake files from the gem inside the main app, or loading a seeds.rb in the gem from the one in the main app.

So what I’m asking is basically how to make the rake db:seed task do things defined within my gemified engine just by having the gem required in the gemfile?

  • 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-10T16:19:03+00:00Added an answer on June 10, 2026 at 4:19 pm

    So shortly after asking this I figured it out.
    First step was taken from here: How to add a gems tasks to the main app

    Then inside a task file

    #lib/task/some_task.rake
    Rake::Task['db:seed'].enhance ['my_seed_task']
    
    #lib/tasks/my_seed_task.rake
    task 'my_seed_task' do
      ...
    end
    

    And now when in the main app I run rake db:seed it runs whatever my_seed_task defines as a perquisite.

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

Sidebar

Related Questions

In my rails application I have a rake task that reads emails using imap.
I have a Rails application using Restful authentication and declarative authorization. I have some
I have a rails application that allows searches using longitude and latitude. I have
I have a Rails 3.2.2 application using Ruby version 1.9.2. I have created basic
I have created a blog application using Ruby on Rails which includes the ability
I have recently started using RSpec for Integration testing in my Rails application, to
I am using haml with my rails application and i have a question how
I have built a very simple blog application using Ruby on Rails. New to
I have rails application running in linode server .Some guy is continuously spamming (writing
I have a rails application, and I authenticate users to the application using Devise.

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.