Acts as ferret issue (in Production)

Hi there - i’m looking for anyone who 's experienced inconsistent
behaviour in ferret:

The search engine is somewhat temperamental, some words are returned,
and some result in a 500 server error…

the error in the log is as follows:. (this is straight off the
production log:

** What’s confusing, is that the engine does return some results, but
not always… I know some words exist in the database, and I have also
reset the ferret server.

Processing BuddiesController#search (for 86.150.12.191 at 2010-01-23
18:06:44) [GET]
Parameters: {“q”=>“craig”}

NoMethodError (undefined method info' for nil:NilClass): app/controllers/buddies_controller.rb:55:insearch’
app/controllers/buddies_controller.rb:55:in search' /usr/lib/ruby/1.8/phusion_passenger/rack/request_handler.rb:92:inprocess_request’
/usr/lib/ruby/1.8/phusion_passenger/abstract_request_handler.rb:
207:in main_loop' /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb: 385:instart_request_handler’
/usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:
343:in handle_spawn_application' /usr/lib/ruby/1.8/phusion_passenger/utils.rb:184:insafe_fork’
/usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb:
341:in handle_spawn_application' /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:insend
/usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in
main_loop' /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:instart_synchronously’
/usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:163:in
start' /usr/lib/ruby/1.8/phusion_passenger/railz/application_spawner.rb: 209:instart’
/usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:262:in
spawn_rails_application' /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb: 126:inlookup_or_add’
/usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:256:in
spawn_rails_application' /usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb: 80:insynchronize’
/usr/lib/ruby/1.8/phusion_passenger/abstract_server_collection.rb:
79:in synchronize' /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:255:inspawn_rails_application’
/usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:154:in
spawn_application' /usr/lib/ruby/1.8/phusion_passenger/spawn_manager.rb:287:inhandle_spawn_application’
/usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:in
__send__' /usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:352:inmain_loop’
/usr/lib/ruby/1.8/phusion_passenger/abstract_server.rb:196:in
`start_synchronously’
/usr/lib/phusion_passenger/passenger-spawn-server:61

Rendering /srv/pistebuddies.com/public/public/500.html (500 Internal
Server Error)

Any ideas?

Many Thanks

On 23 January 2010 18:17, RubyonRails_newbie
[email protected] wrote:

not always… I know some words exist in the database, and I have also
reset the ferret server.

Processing BuddiesController#search (for 86.150.12.191 at 2010-01-23
18:06:44) [GET]
Parameters: {“q”=>“craig”}

NoMethodError (undefined method info' for nil:NilClass): app/controllers/buddies_controller.rb:55:insearch’

It appears that in line 55 of buddies_controller.rb you are calling
something.info where something is nil (the clue is in the error
message). Have a look to see why it might be nil. Post the code
here if you cannot see it.

Colin

Hi Colin,

I’ve been searching the code, but not 100% sure what’s up. It was ok
in dev, so can’t explain it… :slight_smile:

line 55 is this line here: users.each { |user| user.info ||=
Info.new }

Here’s the full code from the buddies_controller:

def search
@title = “Find Buddies”
if params[:q]
query = params[:q]
curr_page = params[:page] || 1
users = User.find_with_ferret(query)
infos = Info.find_with_ferret(query)
hits = infos
users.concat(hits.collect { |hit| hit.user }).uniq!

    users.each  { |user| user.info ||= Info.new }
    users = users.sort_by { |user| user.info.last_name }
    @buddies = users.paginate(:page => curr_page, :per_page => 5)
   end

end

Many, Many thanks!!

2010/1/24 RubyonRails_newbie [email protected]:

   users.each  { |user| user.info ||= Info.new }

It appears that one of the users is nil. Have a look at the Rails
Guide on debugging and use ruby-debug to break into here (you can run
it in production mode with the debugger) and inspect the variables and
see what is happening.

Is is possible that the concat call is appending a nil element?

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs