Infinite loop with codecademy code


I'm having a problem with the final project.

I'm on step 7 of the final project. Running my file would always return the error:
undefined method 'chomp' for nil:NilClass (NoMethodError)

At first I thought I made a mistake in my coding so I tried and copy/paste Codecademy solution and it keeps getting the same error.

Here's a copy of the Codecademy solution for this step :

module Menu

      def menu
        " Welcome to the TodoLister Program!
        This menu will help you use the Task List System
        1) Add
        2) Show
        Q) Quit "

      def show

    module Promptable
      def prompt(message = "Just the facts, ma'am.", symbol = ':> ')
        print message
        print symbol

    class List
      attr_reader :all_tasks

      def initialize
        @all_tasks = []

      def add(task)
        all_tasks << task

      def show

    class Task
      attr_reader :description

      def initialize(description)
        @description = description


    if __FILE__ == $PROGRAM_NAME
      include Menu
      include Promptable
      ml =
      puts 'Please choose from the following list'
      until ['q'].include?(user_input = prompt(show).downcase)
        case user_input
        when '1'
          ml.add('What is the task you would like to accomplish?')))
        when '2'
          puts 'Try again, I did not understand.'
      puts 'Outro - Thanks for using our awesome menuing system!'

I thought maybe it was a problem with Ruby on my computer so I tried it on codecademy labs and it returns nil
When I run it in Ruby course editor it return a problem with unexpected "end".

I'm stuck because I can't test my project so I can't keep going on the following steps.

Anyone can help me on this?


Hmmm...this seems to be working find on my machine. The first step to debug this would be to find the source of undefined method 'chomp' for nil:NilClass (NoMethodError). This is saying that whatever object chomp is being called on is nil.

So, the first thing I'd try to find out is what is chomp being called on and why is it nil?


Thanks for your help.

I solved the problem.

I think I wasn't launching my file the correct way. I was lauching it with C:\Users\User\Documents\my_project\ruby myfile.rb as it was said on the project page.
By using C:\Users\User\Documents\my_project\myfile.rb, it seems to work.

I now have an other small problem.
When creating a task with this script, then showing it, it does not show the tasks names but things like this :

Thanks for your help.


It seems like when the tasks are being shown, it's showing the Ruby Task object instead of their description. So, you need to find a way to display the description for each Task object instead of just the Task object itself.


Aaah. Ok.
That explains things.
Thanks a lot. I get it now. :thumbsup: