Hi Erik Did you get my email in response to one of yours that didn't seem to make it through to the list? From what I can see, I replied directly to you on the 8th June (about 10 minutes before your latest email).
Cheers -- Pat On 08/06/2012, at 11:49 PM, elanderholm wrote: > Pat- > > Third times a charm I hope....stupid google groups. > > It looks like you are hooking in the thinking_sphinx callback with the > before_validation hook. > > starts at line 169 of of active_record.rb in lib/thinking_sphinx > > It looks like this: > if sphinx_index_blocks.empty? > before_validation :define_indexes > before_destroy :define_indexes > end > > > The issue is the index stuff is never hooked in on an update_attribute since > it never calls the validations. update_attribute calls save(false) while > update_attributes calls save with no false. > > Anyway to hook in the index stuff without using before_validation? > > Thanks. > Erik > > On Thursday, June 7, 2012 11:27:53 AM UTC-7, Pat Allan wrote: > Hmm, I thought update_attribute didn't fire callbacks - but it turns out it > does. Not sure if it's always been that way or it's a relatively new change, > but good to know, I guess. Albeit it removes a reason for this inconsistency, > so I'm unsure why it's only happening sometimes. > As for the process for deltas generally, in relation to the delta column: > * When a record is added/edited, it has delta set to true. > * The delta remains set to true until the next full index, at which point > it's set to false and remains set to false, unless the record is later > changed again. > > Hope this helps, although it doesn't answer why update_attribute is only > firing off the delta indexing only sometimes. Have you got a set of commands > that reliably run without the delta indexing happening? > > -- > Pat > > On 07/06/2012, at 5:45 PM, elanderholm wrote: > > > Hi Pat- > > > > It does run the delta if i do update_attributes. > > > > ## Sphinx > > define_index do > > indexes :name, :as => :name, :sortable => true > > indexes makes.name, :as => :makes_name > > indexes zip_code.zip_code, :as => :zip_code > > indexes zip_code.city_name, :as => :city > > indexes zip_code.state_name, :as => :state_name > > indexes zip_code.state_abbr, :as => :state_abbr > > > > indexes :created_at, :sortable => true > > > > has zip_code(:id), :as => :zip_code_id > > has 'RADIANS(zip_codes.latitude)', :as => :latitude, :type > > => :float > > has 'RADIANS(zip_codes.longitude)', :as => :longitude, :type > > => :float > > has makes(:id), :as => :makes_id > > has disabled, :as => :disabled, :type > > => :boolean > > has number_of_offers_made, :as => :offer_count, :type > > => :integer > > has total_time_of_last_x_offers, :as => :time_to_offer, :type > > => :integer > > > > set_property :latitude_attr => "latitude" > > set_property :longitude_attr => "longitude" > > set_property :delta => true > > end > > > > Though it seems like sometimes it does work with just > > update_attribute. It's almost like it works or it doesn't for all the > > objects. But, if it starts working then it works fine until I open a > > new console. I guess what I'm trying to say is it's not consistent. > > It's not like update_attribute never works by itself. Also, once I > > run an update_attributes then update_attribute works. > > > > Also, is this the proper behavior. > > If I use update_attributes to change the name for example, it changes > > the delta from false to true. It's false after running rake ts:index > > for instance. Then the rotate runs and the delta stays true? Is that > > correct? When it doesn't work the delta stays false and never toggles > > to true. > > > > thanks. > > Erik > > > > On Jun 7, 1:48 am, "Pat Allan" <[email protected]> wrote: > >> Hi Erik > >> > >> Can you show us your index definition? Also, does it work if you run > >> update_attributes, as opposed to update_attribute (plural, not singular)? > >> > >> -- > >> Pat > >> > >> On 07/06/2012, at 4:52 AM, elanderholm wrote: > >> > >> > >> > >> > >> > >> > >> > >>> I'm going to do my best to describe what is going on here with all the > >>> detail I can muster! :) > >> > >>> First the gist. When I do object.update_attribute...index_delta does > >>> not run. More then that if I do Class.index_delta(self) it can't find > >>> index_delta. It does not respond_to? it. > >> > >>> If I do object.update_attributes it works fine. It runs the > >>> index_delta after_commit. > >> > >>> I even went as far as to create my own after commit that looked > >>> something like > >> > >>> after_commit do > >>> Class.index_delta(self) > >>> end > >> > >>> and i get a no_method error for the Class if I do update_attribute. > >>> If i do update_attributes it actually ends up rotating the indexes > >>> twice. Once from the thinking_sphinx code and once from my > >>> after_commit. > >> > >>> I'm using > >>> Rails 3.2 > >>> gem 'thinking-sphinx', '~> 2.0.12' > >>> Sphinx 0.9.9-release (r2117) > >> > >>> Thanks > >>> Erik > >> > >>> -- > >>> You received this message because you are subscribed to the Google Groups > >>> "Thinking Sphinx" group. > >>> To post to this group, send email to [email protected]. > >>> To unsubscribe from this group, send email to > >>> [email protected]. > >>> For more options, visit this group > >>> athttp://groups.google.com/group/thinking-sphinx?hl=en. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Thinking Sphinx" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > > http://groups.google.com/group/thinking-sphinx?hl=en. > > > > > > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Thinking Sphinx" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/thinking-sphinx/-/Fkj5sjrAPiAJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/thinking-sphinx?hl=en. -- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
