Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 => 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

This is my environment.rb:

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

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

Thank you!

like image 721
user929062 Avatar asked Sep 26 '11 10:09

user929062


1 Answers

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.

like image 106
monfresh Avatar answered Nov 03 '22 12:11

monfresh