简体   繁体   中英

deprecation warning in Rails

I'm a newbie to Rails and programming in general (currently learning from a book that's using 3.0.1 and ruby 1.9.2).

When I did the rake db:migrate command I got the following deprecation warning. I'm not sure if this is because I'm using a slightly older version of Rails, or if it would happen no matter what the version. Anyways, can anyone tell me what if anything I'm supposed to do now?

As I am a newbie a detailed answer would be very appreciated. Cheers

$ rake db:migrate


WARNING: Global access to Rake DSL methods is deprecated.  Please include
    ...  Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method SampleApp::Application#task called at /Users/michaeljohnmitchell/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.1/lib/rails/application.rb:214:in `initialize_tasks'

Update with rakefile

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rake'

SampleApp::Application.load_tasks

Assuming you're using Rake 0.9.x, you have two options:

  1. Upgrade to at least rails 3.0.8 (which fixes integration with Rake 0.9.x, as stated here ). This can be achieved by changing your gem file to gem rails, '3.0.8' (or higher) and running bundle install .

  2. You could probably downgrade to Rake 0.8.x to fix this warning, but I highly recommend the first option.

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