NUBIC / surveyor

A Rails gem that lets you code surveys, questionnaires, quizzes, etc... and add them to your app.
http://nubic.github.com/surveyor
MIT License
750 stars 273 forks source link

undefined method 'answers' for nil:NilClass #316

Closed mjthompsgb closed 12 years ago

mjthompsgb commented 12 years ago

I get the error "undefined method 'answers' for nil:NilClass" when trying to run "rake surveyor FILE=surveys/kitchen_sink_survey.rb" . I previously had this working on a different rails app but for some reason it won't work on this app. Everything is identical except it is just a fresh install of the server. I have searched and searched to find an answer with no luck. Please help me figure this out.

Thanks Matt

jefflunt commented 12 years ago

Can you verify some information on your environment? Specifically: surveyor gem version, rails version, ruby version, and OS you're deploying too (or deployment platform if you're using Heroku/Engine Yard, etc.)?

Also, does the entire survey import, or does it stop on a particular question? When you do the import it outputs the questions/answers to the command line, and the last one that shows up is where the import process choked.

jdzak commented 12 years ago

Hi Matt,

Which version of surveyor/rails/ruby are you using? Also, can you run rake surveyor FILE=surveys/kitchen_sink_survey.rb --trace and post the full backtrace?

Thanks, John

On Mon, May 7, 2012 at 11:16 AM, mjthompsgb < reply@reply.github.com

wrote:

I get the error "undefined method 'answers' for nil:NilClass" when trying to run "rake surveyor FILE=surveys/kitchen_sink_survey.rb" . I previously had this working on a different rails app but for some reason it won't work on this app. Everything is identical except it is just a fresh install of the server. I have searched and searched to find an answer with no luck. Please help me figure this out.

Thanks Matt


Reply to this email directly or view it on GitHub: https://github.com/NUBIC/surveyor/issues/316

mjthompsgb commented 12 years ago

Thanks for getting back to me so quickly. I should of known to put that stuff in after reading all the other issues I read but forgot.

Surveyor version: 0.22.0 Rails version: 3.1.4 Ruby version: 1.9.2 OS: Red Hat Enterprise Linux Server release 6.2 (Santiago)

I am running Rails on Nginx server with Unicorn. I am also using RVM.

It has an undefined method error for any survey I attempt to import but here is the exact output of running the import on the default kitchen_sink_survey that comes with Surveyor.

--- Parsing /apps/testapp/surveys/kitchen_sink_survey.rb ---

survey survey_section question question_1 answer answer answer answer answer question_2 answer_1 answer_2 answer_3 >answer_4 answer question_2a answer_1 dependency dependency_condition_A dependency_condition_B dependency_condition_C >dependency_condition_D question_2b answer_1 dependency dependency_condition_Z question_montypython3 answer_1 >question_montypython4 answer_1 dependency dependency_condition_A question_montypython5 answer_1 dependency >dependency_condition_A question dependency dependency_condition_A question answer answer answer question answer >validation validation_condition_A question answer validation validation_condition_A question answer question_time_lunch answer_1 >question answer question answer answer answer answer answer answer answer answer answer answer question answer answer >answer answer answer question answer question_group question answer question answer answer answer question answer answer >answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer >answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer >answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer >answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer >answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer >answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer answer >answer answer answer answer question answer answer answer answer answer answer question answer answer answer answer >survey_section question_group answer rake aborted! undefined method answers' for nil:NilClass /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:26:ininstance_eval' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:41:in method_missing' (eval):163:inblock (3 levels) in parse' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:45:in instance_eval' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:45:inmethod_missing' (eval):162:in block (2 levels) in parse' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:45:ininstance_eval' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:45:in method_missing' (eval):159:inblock in parse' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:45:in instance_eval' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:45:inmethod_missing' (eval):1:in parse' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:26:ininstance_eval' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:26:in parse' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/surveyor/parser.rb:13:inparse' /usr/local/rvm/gems/ruby-1.9.2-p320@rails3.1.4/gems/surveyor-0.22.0/lib/tasks/surveyor_tasks.rake:10:in block (2 levels) in <top >(required)>' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:incall' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in block in execute' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:ineach' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in execute' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:inblock in invoke_with_call_chain' /usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:ininvoke_with_call_chain' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in block in invoke_prerequisites' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:ineach' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in invoke_prerequisites' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:inblock in invoke_with_call_chain' /usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:ininvoke_with_call_chain' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in invoke' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:ininvoke_task' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block (2 levels) in top_level' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:ineach' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block in top_level' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in top_level' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:inblock in run' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:inrun' /usr/local/rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/bin/rake:33:in <top (required)>' /usr/local/rvm/gems/ruby-1.9.2-p320@global/bin/rake:19:inload' /usr/local/rvm/gems/ruby-1.9.2-p320@global/bin/rake:19:in `

' Tasks: TOP => surveyor => surveyor:parse

The error is essentially the same for any survey I try to import but the undefined method is different for each.

Let me know if you need any more info or want me to try something.

Thanks again. Matt

mjthompsgb commented 12 years ago

It appears to be aborting at the spot in the survey file where Grids are used. Line 161 or around there.

mjthompsgb commented 12 years ago

I am not sure what was wrong with my previous server setup and the Surveyor install but I reinstalled everything that had to do with RoR and reinstalled Surveyor and now it works. Wasn't a surveyor issue though so that is good. Thanks for taking anytime you did to look into it though.

Thanks Matt