简体   繁体   中英

rails 3.0.12 update - why are the rake tasks of this gem not loaded?

I'm updating a rails 2.x app to rails 3.0.12.

This app used the bootstrapper gem to "seed" the database. The original fork of the gem seems to have stopped in the rails 2.x branch, but I found this other fork which is (in theory) compatible with rails 3.2 (notice that I'm updating to 3.0.12, not 3.2).

So this is what my Gemfile has now:

gem 'bootstrapper', :git => 'git://github.com/vivrass/bootstrapper.git'

After running bundle update, this seems to work... except that the gem is supposed to add a new rake task called rake db:bootstrap , and it doesn't appear when I execute rake -T db (which I have aliased to bundle exec rake -T db via oh-my-zsh).

rake db:create                         # Create the database from config/database.yml for the current Rails.env (use db:crea...
rake db:drop                           # Drops the database for the current Rails.env (use db:drop:all to drop all databases)
rake db:fixtures:load                  # Load fixtures into the current environment's database.
rake db:migrate                        # Migrate the database (options: VERSION=x, VERBOSE=false).
rake db:migrate:status                 # Display status of migrations
rake db:rollback                       # Rolls the schema back to the previous version (specify steps w/ STEP=n).
rake db:schema:dump                    # Create a db/schema.rb file that can be portably used against any DB supported by AR
rake db:schema:load                    # Load a schema.rb file into the database
rake db:seed                           # Load the seed data from db/seeds.rb
rake db:setup                          # Create the database, load the schema, and initialize with the seed data (use db:res...
rake db:structure:dump                 # Dump the database structure to an SQL file
rake db:version                        # Retrieves the current schema version number

I've checked the repo, and according to this post it seems that the gem is doing the right things: - It has a railtie.rb file which loads the rake file - The railtie.rb file is included in the lib/bootstraper.rb file

And yet, the rake task doesn't appear.

Has the process of adding rake tasks to a gem changed from rails 3.0.x to 3.2.x in any significant way?

I'm running ruby 1.9.3.

Thanks.

EDIT:

I created a new empty rails project in rails 3.0.12, added the line on the Gemfile, and after bundling, the rake task appears. This might be related with the fact that I'm updating from rails 2.x instead of creating a brand new rails 3.0.12 project.

Ok, found the problem.

The old (rails 2.x) bootstrapper gem needed a file called lib/tasks/bootstrapper.rake . I sill had that file on my rails project, and it was messing around with the rake tasks. Removing the file solved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM