Hey all

I have a line of code that's causing a "undefined method `include?' for
nil:NilClass" exception, but i can't work out what's actually going
wrong with it.  After a bit of experimentation i discovered that it's
caused by simply asking for the id of an AR object i have.

          ldb "question.id = #{question.id}"

ldb is just a logging method i have - it's not the problem as i got the
same error initially when i tried to use question.id in a find call.
Here's the line with some other logging output and the stack trace:

          ldb "options = #{options.inspect}"
          ldb "question = #{question.inspect}"
          ldb "question.id = #{question.id}"

stack trace and debug logger output:

### ./app/models/quiz.rb:458:in `auto_generate_quizzes_from_questions':
options = {:age_group_id=>3, :style=>"sequential", :tag=>#<Tag id: 60,
name: "speaking", created_at: nil>, :size=>6}
### ./app/models/quiz.rb:459:in `auto_generate_quizzes_from_questions':
question = #<Question id: 619, text: "Which of these words has only one
syllable?", kind: "text", media_instruction_text: nil, qid: "619",
editor_id: 22, editor_name: "Ian McNeilly", user_id: 15, author_ext_id:
"22", original_target_age: "11", qtype: "Curriculum", keywords: "--- \n-
Curriculum\n- English\n- School\n- Which\n- has\n...", created_at:
"2010-02-25 13:20:02", updated_at: "2010-04-01 16:17:03", checked:
false, subject_id: 1, official: nil, privacy: 1>

NoMethodError (undefined method `include?' for nil:NilClass):
  lib/core_extensions.rb:6:in `method_missing'
  app/models/quiz.rb:460:in `auto_generate_quizzes_from_questions'
  app/models/quiz.rb:456:in `each'
  app/models/quiz.rb:456:in `auto_generate_quizzes_from_questions'
  app/controllers/admin/subjects_controller.rb:9:in `make_quizzes'
  vendor/plugins/haml/rails/./lib/sass/plugin/rack.rb:44:in `call'
  /usr/lib/ruby/1.8/mongrel/rails.rb:76:in `process'
  /usr/lib/ruby/1.8/mongrel/rails.rb:74:in `synchronize'
  /usr/lib/ruby/1.8/mongrel/rails.rb:74:in `process'
  /usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'
  /usr/lib/ruby/1.8/mongrel.rb:158:in `each'
  /usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `run'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `new'
  /usr/lib/ruby/1.8/mongrel.rb:285:in `run'
  /usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'
  /usr/lib/ruby/1.8/mongrel.rb:268:in `new'
  /usr/lib/ruby/1.8/mongrel.rb:268:in `run'
  /usr/lib/ruby/1.8/mongrel/configurator.rb:282:in `run'
  /usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `each'
  /usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `run'
  /usr/lib/ruby/1.8/mongrel/command.rb:212:in `run'

Line 460 is the last one listed above.  I can see from the debug output
that question is a regular AR object.

The reason that i thought it might be memcache/interlock related is that
if i restart mongrel then it magically works.  Then the second time i
try it it breaks again.  This is totally consistent, it always works
first time after restart and fails every subsequent time.

kind of stumped - any ideas anyone?

thanks, max
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to