On 04/04/2011 09:41 PM, Matt Wagner wrote:
By default, authlogic updates a User record on every page load,
and sunspot updates Solr every time a record is changed. This
results in an absurd volume of unnecessary Solr updates.
---
src/app/models/user.rb | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/app/models/user.rb b/src/app/models/user.rb
index 4d95adc..ead459a 100644
--- a/src/app/models/user.rb
+++ b/src/app/models/user.rb
@@ -48,7 +48,8 @@
require 'sunspot_rails'
class User< ActiveRecord::Base
- searchable do
+ non_solr_attributes = [:single_access_token, :last_request_at, :created_at, :quota_id,
:crypted_password, :updated_at, :perishable_token, :failed_login_count, :current_login_ip,
:password_salt, :current_login_at, :persistence_token, :login_count, :last_login_ip,
:last_login_at]
+ searchable :ignore_attribute_changes_of => non_solr_attributes do
text :login, :as => :code_substring
text :last_name, :as => :code_substring
text :first_name, :as => :code_substring
ACK.
As for the last_request_at suggestion, we're looking at switching from
Authlogic to Devise[1]. As such, I recommend we postpone that discussion.
Thomas
[1]:
https://github.com/plataformatec/devise