【问题标题】:rails 3.0.12 update - why are the rake tasks of this gem not loaded?rails 3.0.12 更新 - 为什么这个 gem 的 rake 任务没有加载?
【发布时间】:2012-04-21 17:49:38
【问题描述】:

我正在将 rails 2.x 应用程序更新到 rails 3.0.12。

此应用使用引导程序 gem 来“播种”数据库。 gem 的original fork 似乎已经停止在 rails 2.x 分支,但我发现这个(理论上)与 rails 3.2 兼容的另一个分支(请注意,我正在更新到 3.0.12,而不是 3.2) .

这就是我的 Gemfile 现在拥有的:

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

运行包更新后,这似乎工作......除了 gem 应该添加一个名为 rake db:bootstrap 的新 rake 任务,并且当我执行 rake -T db 时它不会出现(我已将其别名为bundle exec rake -T db 通过 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

我检查了 repo,根据this post 看来 gem 正在做正确的事情: - 它有一个railtie.rb 文件,用于加载rake file - railtie.rb 文件包含在lib/bootstraper.rb file

然而,rake 任务并没有出现。

将 rake 任务添加到 gem 的过程是否从 rails 3.0.x 更改为 3.2.x?

我正在运行 ruby​​ 1.9.3。

谢谢。

编辑:

我在rails 3.0.12新建了一个空rails项目,在Gemfile上添加了这行,打包后出现rake任务。这可能与我从 rails 2.x 更新而不是创建全新的 rails 3.0.12 项目这一事实有关。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 rubygems rake


    【解决方案1】:

    好的,找到问题了。

    旧的 (rails 2.x) 引导程序 gem 需要一个名为 lib/tasks/bootstrapper.rake 的文件。我在我的 rails 项目中有那个文件,它正在处理 rake 任务。删除文件解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2012-07-13
      • 2016-06-21
      • 1970-01-01
      • 2012-12-01
      • 2013-03-04
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      • 2018-01-05
      相关资源
      最近更新 更多