Hi Pat, Thanks for the solution.
Removing :type=>:datetime solved the problem. :) -Surbhi On Thu, Oct 28, 2010 at 4:37 AM, Pat Allan <[email protected]> wrote: > I would remove the :type option from that filter - as it's not a single > datetime value, but a collection of them (:multi). Though I'm not sure if > that's the problem you're seeing here... > > What happens if you just write: > has comments.created_at, :as => :comments_created_at > > -- > Pat > > On 28/10/2010, at 2:51 AM, Surbhi wrote: > > > Hi, > > > > I have the following model > > > > class Post < ActiveRecord::Base > > # Sphinx server indexing > > has_many :comments > > define_index do > > #fields > > indexes title > > has > > comments(:created_at),:as=> :comment_created_at, :type=> :datetime > > has created_at, :type => :datetime > > end > > end > > > > Now, I have a model named Comment. > > > > Scenario: I want to search for posts which have comments created in a > > given date range. > > > > For this I have added attribute " has > > comments(:created_at),:as=> :comment_created_at, :type=> :datetime" > > > > Issue: When I create a new post it gives the folloiwng error: > > > > > > NoMethodError: undefined method `created_at' for []:Array > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/associations/association_proxy.rb:148:in `send' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/associations/association_proxy.rb:148:in `send' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/attribute.rb:187:in `live_value' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/active_record/attribute_updates.rb:37:in > > `attribute_values_for_ > > index' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/base.rb:2036:in `inject' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/active_record/attribute_updates.rb:36:in `each' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/active_record/attribute_updates.rb:36:in `inject' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/active_record/attribute_updates.rb:36:in > > `attribute_values_for_ > > index' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/active_record/attribute_updates.rb:17:in > > `update_attribute_valu > > es' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/active_record/attribute_updates.rb:16:in `each' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/thinking- > > sphinx-1.3.20/lib > > /thinking_sphinx/active_record/attribute_updates.rb:16:in > > `update_attribute_valu > > es' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activesupport-2.3.5/lib/ac > > tive_support/callbacks.rb:178:in `send' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activesupport-2.3.5/lib/ac > > tive_support/callbacks.rb:178:in `evaluate_method' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activesupport-2.3.5/lib/ac > > tive_support/callbacks.rb:166:in `call' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activesupport-2.3.5/lib/ac > > tive_support/callbacks.rb:93:in `run' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activesupport-2.3.5/lib/ac > > tive_support/callbacks.rb:92:in `each' > > ... 1 levels... > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activesupport-2.3.5/lib/ac > > tive_support/callbacks.rb:92:in `run' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activesupport-2.3.5/lib/ac > > tive_support/callbacks.rb:276:in `run_callbacks' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/callbacks.rb:344:in `callback' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > after_commit-1.0.8/lib/aft > > er_commit/connection_adapters.rb:129:in `send' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > after_commit-1.0.8/lib/aft > > er_commit/connection_adapters.rb:129:in > > `trigger_after_commit_callbacks' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > after_commit-1.0.8/lib/aft > > er_commit/connection_adapters.rb:128:in `each' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > after_commit-1.0.8/lib/aft > > er_commit/connection_adapters.rb:128:in > > `trigger_after_commit_callbacks' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > after_commit-1.0.8/lib/aft > > er_commit/connection_adapters.rb:36:in `commit_db_transaction' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/connection_adapters/abstract/database_statements.rb:159:in > > `transacti > > on_without_callback' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > after_commit-1.0.8/lib/aft > > er_commit/connection_adapters.rb:12:in `transaction' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/transactions.rb:182:in `transaction' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/transactions.rb:228:in `with_transaction_returning_status' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/transactions.rb:196:in `save' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/transactions.rb:208:in `rollback_active_record_state!' > > from F:/Softwares/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/act > > ive_record/transactions.rb:196:in `save' > > from (irb):2>> > > > > -- > > 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]<thinking-sphinx%[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]<thinking-sphinx%[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.
