Can you get the value of list.send(:latitude_attr)?
--
Pat
On 30/07/2009, at 6:09 PM, Andrew Lippert wrote:
>
> On line #16 of app/views/members/_list.html.erb
> 13: num_per_page = is_cat ? Member.per_cat_page : Member.per_page
> 14: path = is_cat ? "/#...@city[:name].downcase.gsub(/\s/, '-')}/#
> {[email protected]}" : search_path('members')
> 15:
> 16: if list.total_entries > 0
> 17:
> 18: -%>
> 19:
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/
> riddle/lib/riddle/client/message.rb:20:in `send'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/
> riddle/lib/riddle/client/message.rb:20:in `append_string'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/
> riddle/lib/riddle/client.rb:531:in `query_message'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./vendor/
> riddle/lib/riddle/client.rb:286:in `query'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/
> thinking_sphinx/search.rb:203:in `populate'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/
> thinking_sphinx/search.rb:279:in `call'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/
> thinking_sphinx/search.rb:279:in `retry_on_stale_index'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/
> thinking_sphinx/search.rb:200:in `populate'
> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/
> thinking_sphinx/search.rb:149:in `total_entries'
> app/views/members/_list.html.erb:16
> app/views/search/members.html.erb:14
> app/views/search/members.html.erb:12
> app/controllers/search_controller.rb:103:in `members'
> passenger (2.2.4) lib/phusion_passenger/rack/request_handler.rb:91:in
> `process_request'
> passenger (2.2.4) lib/phusion_passenger/abstract_request_handler.rb:
> 206:in `main_loop'
> passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:
> 376:in `start_request_handler'
> passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:
> 334:in `handle_spawn_application'
> passenger (2.2.4) lib/phusion_passenger/utils.rb:182:in `safe_fork'
> passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:
> 332:in `handle_spawn_application'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in
> `__send__'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in
> `main_loop'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:195:in
> `start_synchronously'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:162:in
> `start'
> passenger (2.2.4) lib/phusion_passenger/railz/application_spawner.rb:
> 213:in `start'
> passenger (2.2.4) lib/phusion_passenger/railz/framework_spawner.rb:
> 291:in `handle_spawn_application'
> passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:
> 126:in `lookup_or_add'
> passenger (2.2.4) lib/phusion_passenger/railz/framework_spawner.rb:
> 286:in `handle_spawn_application'
> passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:
> 80:in `synchronize'
> passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:
> 79:in `synchronize'
> passenger (2.2.4) lib/phusion_passenger/railz/framework_spawner.rb:
> 284:in `handle_spawn_application'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in
> `__send__'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in
> `main_loop'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:195:in
> `start_synchronously'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:162:in
> `start'
> passenger (2.2.4) lib/phusion_passenger/railz/framework_spawner.rb:
> 101:in `start'
> passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:261:in
> `spawn_rails_application'
> passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:
> 126:in `lookup_or_add'
> passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:255:in
> `spawn_rails_application'
> passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:
> 80:in `synchronize'
> passenger (2.2.4) lib/phusion_passenger/abstract_server_collection.rb:
> 79:in `synchronize'
> passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:254:in
> `spawn_rails_application'
> passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:153:in
> `spawn_application'
> passenger (2.2.4) lib/phusion_passenger/spawn_manager.rb:286:in
> `handle_spawn_application'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in
> `__send__'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:351:in
> `main_loop'
> passenger (2.2.4) lib/phusion_passenger/abstract_server.rb:195:in
> `start_synchronously'
>
> On Jul 30, 10:05 am, Pat Allan <[email protected]> wrote:
>> Hmm, okay. Can you give me the latest stack trace when running from a
>> view?
>>
>> --
>> Pat
>>
>> On 30/07/2009, at 5:41 PM, Andrew Lippert wrote:
>>
>>
>>
>>
>>
>>> Example console output:
>>
>>>>> members =
>>>>> Search
>>>>> .member_search_sphinx
>>>>> ({"search"=>{"local"=>"1","origin"=>[47.60342,
>>>>> -122.32971
>>>>> ],"terms
>>>>> "=
>>
>>>>> "cto
>>>>> ","page
>>>>> "=
>>
>>>>> "5
>>>>> ","limit
>>>>> "=
>>
>>>>> 5
>>>>> ,"distance
>>>>> "=>"50"},"action"=>"members","controller"=>"search","page"=>"1"})
>>> => [#<Member id: 30976, login: "[email protected]", first_name: "Iliane",
>>> last_name: "Borge", what_i_do: "<a href=\"http://www.facebook.com/
>>> pages/PostHorsesco...", needs: "People that want to buy or sell
>>> horses
>>> or just conn...", specialties: "Connect people! I love to connect
>>> people and see th...", education: " I grew up and went to school
>>> near
>>> Wiesbaden in Ger...", experience: "I studied with IBM at a corporate
>>> univeristy in Man...", how_heard: "We got contacted through meetup
>>> and
>>> then met with K...", invited_by_id: nil, is_featured: true,
>>> membership_level_id: 2, participation_level_id: nil,
>>> participation_points: 26843, email_list_subscriber: true,
>>> show_profile_views: true, accepts_terms: true, meta_description:
>>> nil,
>>> receive_stats: true, permalink: "iliane-borge-1", gender: "f",
>>> date_of_birth: "1981-04-16", signup_ip: "71.145.143.124",
>>> last_mod_ip:
>>> nil, topics_count: nil, posts_count: 15, primary_business_title:
>>> "Equestrian Online Classifieds, Equine Photography, ...",
>>> primary_business_location: "Austin, Texas", primary_business_lat:
>>> "30.4413", primary_business_long: "-97.8017", has_primary_image:
>>> true,
>>> primary_image_icon: "/images/members/icon/
>>> 2006__02_16_bizcards_063_flat....", primary_image_mini: "/images/
>>> members/mini/2006__02_16_bizcards_063_flat....",
>>> primary_image_thumb:
>>> "/images/members/thumb/2006__02_16_bizcards_063_flat...",
>>> membership_level_title: "active", activation_code: "activated",
>>> published_at: "2009-04-08 20:19:59", activated_at: "2009-04-08
>>> 20:19:59", profiled_at: nil, last_seen_at: "2009-07-29 16:51:42",
>>> created_at: "2009-04-08 20:18:04", updated_at: "2009-07-28
>>> 21:22:36",
>>> deleted_at: nil, needs_updated_at: "2009-07-20 00:29:24",
>>> last_active_at: nil, time_zone: "UTC", profile_updated_at:
>>> "2009-07-25
>>> 19:41:43", sig_text: nil, sig_link: nil, bio: nil, is_exceptional:
>>> false, current_city: "Austin", delta: false>,
>>
>>>>> members.total_entries
>>> => 33216
>>>>> members.total_pages
>>> => 1108
>>>>> members.per_page
>>> => 30
>>
>>> etc.
>>
>>> It is returning the proper results as far as I can tell.
>>> On Jul 30, 9:20 am, Pat Allan <[email protected]> wrote:
>>>> Yeah, didn't think that'd be the cause. Ah well.
>>
>>>> What are the parameters being used in the request? Have you tried
>>>> the
>>>> exact same query in script/console? Also, when running in script/
>>>> console, have you actually checked the array contents? TS 1.2
>>>> doesn't
>>>> request results from Sphinx until they're actually needed - hence
>>>> why
>>>> the error is happening in the view, not the controller.
>>
>>>> --
>>>> Pat
>>
>>>> On 30/07/2009, at 5:09 PM, Andrew Lippert wrote:
>>
>>>>> I removed the set_properties for lat/lng with no change. I had
>>>>> high
>>>>> hopes it was something really strange related to your comment
>>>>> above.
>>>>> Now we are back to something directly related to my incompetence.
>>>>> Bummer.
>>
>>>>> On Jul 30, 9:05 am, Andrew Lippert <[email protected]> wrote:
>>>>>> Sorry!!
>>
>>>>>> def self.member_search_sphinx(criteria, vip=false)
>>>>>> return Member.sphinx_search(criteria[:terms],
>>>>>> :page => criteria[:page],
>>>>>> :limit => criteria[:limit],
>>>>>> :origin => criteria[:origin],
>>>>>> :distance =>
>>>>>> criteria[:distance],
>>>>>> :vip => vip)
>>>>>> end
>>
>>>>>> I'll check the lat/lng stuff.
>>
>>>>>> On Jul 30, 9:01 am, Pat Allan <[email protected]> wrote:
>>
>>>>>>> Response times ebb and flow - you're just lucky you caught me at
>>>>>>> the
>>>>>>> latter :)
>>
>>>>>>> You've provided Member.sphinx_search, but you're using
>>>>>>> Search.member_search_sphinx - got the code for the latter?
>>
>>>>>>> Also, it seems the error is happening when the latitude
>>>>>>> attribute is
>>>>>>> being set - you don't actually need the set_property calls for
>>>>>>> the
>>>>>>> lat/
>>>>>>> lng attributes, because your names for them are guessable by
>>>>>>> Thinking
>>>>>>> Sphinx. If you wish to keep them anyway, try having the values
>>>>>>> as
>>>>>>> symbols, not strings (not that it should make a difference,
>>>>>>> especially
>>>>>>> if everything works in development).
>>
>>>>>>> Cheers
>>
>>>>>>> --
>>>>>>> Pat
>>
>>>>>>> On 30/07/2009, at 4:49 PM, Andrew Lippert wrote:
>>
>>>>>>>> Pat,
>>
>>>>>>>> I'm amazed at your response time!
>>
>>>>>>>> Everything is working fine in development. It is only the
>>>>>>>> production
>>>>>>>> server that is having problems. So, I'm sure I've missed
>>>>>>>> something
>>>>>>>> crucial.
>>
>>>>>>>> Here's the code:
>>
>>>>>>>> Model -
>>
>>>>>>>> define_index do
>>>>>>>> # fields
>>>>>>>> indexes first_name
>>>>>>>> indexes last_name
>>>>>>>> indexes [first_name, last_name], :as => :full_name
>>>>>>>> indexes permalink
>>>>>>>> indexes primary_business_title
>>>>>>>> indexes primary_business_location
>>>>>>>> indexes what_i_do
>>>>>>>> indexes needs
>>>>>>>> indexes specialties
>>>>>>>> indexes experience
>>>>>>>> indexes education
>>>>>>>> indexes categories.name, :as => :categories
>>>>>>>> indexes taggings.tag.name, :as => :tags
>>
>>>>>>>> # attributes
>>>>>>>> has membership_level_id, participation_points
>>>>>>>> has '(membership_level_id + has_primary_image * 150) +
>>>>>>>> IFNULL
>>>>>>>> (participation_points + 1, 1)', :as => :rating, :type
>>>>>>>> => :integer
>>>>>>>> has 'RADIANS(primary_business_lat)', :as => :lat, :type
>>>>>>>> => :float
>>>>>>>> has 'RADIANS(primary_business_long)', :as => :lng, :type
>>>>>>>> => :float
>>
>>>>>>>> # properties
>>>>>>>> set_property :latitude_attr => 'lat'
>>>>>>>> set_property :longitude_attr => 'lng'
>>>>>>>> set_property :field_weights => {:categories =>
>>>>>>>> 5, :primary_business_title => 4, :what_i_do => 3}
>>>>>>>> set_property :delta => :delayed
>>
>>>>>>>> # filter
>>>>>>>> where "deleted_at IS NULL AND activated_at IS NOT NULL"
>>
>>>>>>>> end
>>
>>>>>>>> def self.sphinx_search(terms = "", options ={})
>>>>>>>> limit = options.delete(:limit) || self.per_page
>>>>>>>> page = (options.delete(:page) || 1).to_i
>>>>>>>> page = (page < 1) ? 1 : page
>>>>>>>> vip = options.delete(:vip) || false
>>>>>>>> limit = self.vip_per_page if vip
>>>>>>>> fields = options.delete(:fields)
>>>>>>>> distance = options.delete(:distance) ||
>>>>>>>> Session.default_distance
>>>>>>>> || self.default_distance
>>
>>>>>>>> @search_options = { :page => page,
>>>>>>>> :per_page => limit,
>>>>>>>> :star => true,
>>>>>>>> :match_mode => :extended }
>>
>>>>>>>> if origin = options.delete(:origin)
>>>>>>>> lat = (origin[0] / 180.0) * Math::PI
>>>>>>>> lng = (origin[1] / 180.0) * Math::PI
>>>>>>>> distance = distance.to_i * 1609.344
>>>>>>>> @search_options.merge!(:geo => [lat, lng], :with =>
>>>>>>>> { "@geodist"
>>>>>>>> => 0.0..distance })
>>>>>>>> end
>>
>>>>>>>> if vip
>>>>>>>> @search_options.merge!(:without =>
>>>>>>>> { :membership_level_id =>
>>>>>>>> 1..2 })
>>>>>>>> end
>>
>>>>>>>> @search_options.merge!(:sort_mode => :expr,
>>>>>>>> :sort_by => '@weight * 1.5 + rating'
>>>>>>>> )
>>
>>>>>>>> results = self.search(terms, @search_options)
>>
>>>>>>>> end
>>
>>>>>>>> Controller -
>>
>>>>>>>> @members = Search.member_search_sphinx(@tmp_param[:search])
>>
>>>>>>>> View -
>>
>>>>>>>> members.html.erb:
>>
>>>>>>>> <div id="search_results">
>>>>>>>> <%= render :partial => 'members/list', :object => @members
>>>>>>>> %>
>>>>>>>> </div>
>>
>>>>>>>> _list.html.erb
>>
>>>>>>>> <%-
>>
>>>>>>>> # members / list
>>
>>>>>>>> list ||= @members
>>>>>>>> paginate = true if paginate.nil?
>>>>>>>> size ||= 'icon'
>>>>>>>> up ||= 3
>>
>>>>>>>> # little shortcut
>>>>>>>> is_cat = (params[:action] == "category")
>>>>>>>> num_per_page = is_cat ? Member.per_cat_page : Member.per_page
>>>>>>>> path = is_cat ? "/#...@city[:name].downcase.gsub(/\s/, '-')}/#
>>>>>>>> {[email protected]}" : search_path('members')
>>
>>>>>>>> if list.total_entries > 0
>>
>>>>>>>> -%>
>>
>>>>>>>> Exception:
>>
>>>>>>>> ActionView::TemplateError: You have a nil object when you
>>>>>>>> didn't
>>>>>>>> expect it! You might have expected an instance of Array. The
>>>>>>>> error
>>>>>>>> occurred while evaluating nil.length
>>
>>>>>>>> On line #16 of app/views/members/_list.html.erb
>>
>>>>>>>> 13: num_per_page = is_cat ? Member.per_cat_page :
>>>>>>>> Member.per_page
>>
>>>>>>>> 14: path = is_cat ? "/#...@city[:name].downcase.gsub(/\s/,
>>>>>>>> '-')}/#
>>>>>>>> {[email protected]}" : search_path('members')
>>
>>>>>>>> 15:
>>
>>>>>>>> 16: if list.total_entries > 0
>>
>>>>>>>> 17:
>>
>>>>>>>> 18: -%>
>>
>>>>>>>> 19:
>>
>>>>>>>> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./
>>>>>>>> vendor/
>>>>>>>> riddle/lib/riddle/client/message.rb:20:in `send'
>>
>>>>>>>> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./
>>>>>>>> vendor/
>>>>>>>> riddle/lib/riddle/client/message.rb:20:in `append_string'
>>
>>>>>>>> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./
>>>>>>>> vendor/
>>>>>>>> riddle/lib/riddle/client.rb:531:in `query_message'
>>
>>>>>>>> [GEM_ROOT]/gems/freelancing-god-thinking-sphinx-1.2.1/lib/./
>>>>>>>> vendor/
>>>>>>>> riddle/lib/riddle/client.rb:286:in `query'...
>>
>> read more ยป
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---