2010/1/24 RubyonRails_newbie <[email protected]>:
> 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.. :-)
>
> 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 }

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

>        users = users.sort_by { |user| user.info.last_name }
>       �...@buddies = users.paginate(:page => curr_page, :per_page => 5)
>       end
> end
>
> Many, Many thanks!!
>
>
>
> On 23 Jan, 20:32, Colin Law <[email protected]> wrote:
>> On 23 January 2010 18:17, RubyonRails_newbie
>>
>>
>>
>>
>>
>> <[email protected]> wrote:
>> > 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:in `search'
>>
>> 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
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" 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/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to