acts_as_indexed icon indicating copy to clipboard operation
acts_as_indexed copied to clipboard

Rails 4 Deprecation Warnings

Open steelheaddigital opened this issue 10 years ago • 4 comments

Deprecation warnings with Rails 4.0.8 and ActiveRecord 4.0.8 when using find_with_index.

This code: my_search_results = Post.find_with_index('my search query')

will cause the following deprecation warnings:

DEPRECATION WARNING: ActiveRecord::Base#with_scope and #with_exclusive_scope are deprecated. Please use ActiveRecord::Relation#scoping instead. (You can use #merge to merge multiple scopes together.)

DEPRECATION WARNING: Calling #find(:all) is deprecated. Please call #all directly instead. You have also used finder options. These are also deprecated. Please build a scope instead of using finder options

DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. Post.where(published: true).load). If you want to get an array of records from a relation, you can call #to_a (e.g. Post.where(published: true).to_a)

steelheaddigital avatar Jul 30 '14 12:07 steelheaddigital

In Rails 4.1. these are no longer deprecation warnings, but errors:

Tip.find_with_index('foo') NoMethodError: undefined method `with_scope' for Tip (call 'Tip.connection' to establish a connection):Class

mameier avatar Aug 04 '14 16:08 mameier

Fix for this later in the week.

Thanks for the reports.

dougal avatar Aug 04 '14 16:08 dougal

Tip to users: If you want to use the gem on Rails 4.1, and is getting undefined method `with_scope', try using the :ids_only option (see docs) and then use the ids you got on Model.where(id: ids)

I'm waiting for a fix, but sometimes you have a short deadline :)

carlosvini avatar Aug 18 '14 13:08 carlosvini

Hi dugal, could you possibly include the patch of recotan (https://github.com/rekotan/acts_as_indexed/commit/923325c48f241c6739aa0f1befb3fbbe20e69ad3), it obviously fixes the deprecation in a simple way.

mameier avatar Sep 13 '15 10:09 mameier

I believe my recent changes have replaced this code.

ryankopf avatar Aug 22 '23 16:08 ryankopf