开发者

Rspec with rails 3.1 gives DEPRECATION WARNING ActiveRecord::Associations::AssociationCollection is deprecated?

开发者 https://www.devze.com 2023-04-08 06:46 出处:网络
I upgraded to rails 3.1 and I have some problems with my tests now that worked perfectly before. I get the following warning before the tests:

I upgraded to rails 3.1 and I have some problems with my tests now that worked perfectly before.

I get the following warning before the tests:

DEPRECATION WARNING: ActiveRecord::Associations::AssociationCollection is deprecated! Use ActiveRecord::Associations::CollectionProxy instead. (called from at /home/user/rails_projects/project/config/environment.rb:5)

How can I use CollectionProxy instead of AssociationCollection?

Here is my 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 => f开发者_如何转开发alse
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

This is my environment.rb:

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

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

Thank you!


I had the same problem and fixed it by upgrading to the latest version of will_paginate. So, change this: gem 'will_paginate', '3.0.pre2'

to this: gem "will_paginate", "~> 3.0.2"

Save your Gemfile then do bundle install.

0

精彩评论

暂无评论...
验证码 换一张
取 消