dougal / acts_as_indexed

Acts As Indexed is a plugin which provides a pain-free way to add fulltext search to your Ruby on Rails app
http://douglasfshearer.com/blog/rails-plugin-acts_as_indexed
MIT License
211 stars 49 forks source link

Rails 4 Deprecation Warnings #54

Closed steelheaddigital closed 1 year ago

steelheaddigital commented 10 years ago

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)

mameier commented 10 years ago

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

dougal commented 10 years ago

Fix for this later in the week.

Thanks for the reports.

carlosvini commented 10 years ago

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 :)

mameier commented 9 years ago

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.

ryankopf commented 1 year ago

I believe my recent changes have replaced this code.