带有rails 3.1的Rspec给出了DEPRECATION WARNING ActiveRecord :: Associations :: AssociationCollection不推荐使用?

时间:2011-09-26 10:46:36

标签: ruby-on-rails ruby-on-rails-3 rspec rspec2

我升级到rails 3.1并且我的测试现在遇到了一些问题,之前完美无缺。

我在测试前收到以下警告:

DEPRECATION警告:不推荐使用ActiveRecord :: Associations :: AssociationCollection!请改用ActiveRecord :: Associations :: CollectionProxy。 (从/home/user/rails_projects/project/config/environment.rb:5调用)

如何使用CollectionProxy而不是AssociationCollection?

这是我的Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.0'
gem 'jquery-rails'
gem "therubyracer", "~> 0.9.4"

gem 'carrierwave', '0.5.6'
gem 'haml', '~>3.1.2'
gem 'mysql2', '0.3.7'
gem 'rmagick', '2.13.1'
gem 'sitemap_generator', '2.0.1'
gem 'whenever', '0.6.8', :require => false
gem 'will_paginate', '3.0.pre2'

group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

group :development do
  gem 'rspec-rails', '2.6.1'
  gem 'annotate-models', '1.0.4'
  gem 'faker', '0.9.5', :require => false
  gem 'ruby-debug19', '0.11.6'
end

group :test do
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.3'
  gem 'factory_girl_rails', '1.0'
  gem 'spork', '~> 0.9.0.rc'
end

这是我的environment.rb:

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Project::Application.initialize!

谢谢!

1 个答案:

答案 0 :(得分:18)

我遇到了同样的问题并通过升级到最新版本的will_paginate来修复它。所以,改变这个:gem'will_paginate','3.0.pre2'

到此:gem“will_paginate”,“〜> 3.0.2”

保存您的Gemfile然后进行捆绑安装。