Search code examples
rubymethodsundefinednomethoderror

`<top (required)>': undefined method `“raf_ebooks' for main:Object (NoMethodError) -


When trying to run my twitter_ebooks bot using ruby run.rb I get this error:

Faraday::Builder is now Faraday::RackBuilder.
/Users/Rafi/Desktop/my_ebooks/bots.rb:14:in `<top (required)>': undefined method `“raf_ebooks' for main:Object (NoMethodError)
    from run.rb:33:in `require_relative'
    from run.rb:33:in `<main>'

Here is the git repo, of the bot I'm using, if that helps: https://github.com/mispy/twitter_ebooks

Here is what is inside the bots.rb file (I have removed the auth tokens and consumer key etc for security): http://pastebin.com/gYqcMYhM

What does this error mean and how can I fix it? Thanks.

EDIT: I tried running it again after restarting got pretty much the same error except instead of my_ebooks/bots.rb:14 it says my_ebooks/bots.rb:13

Faraday::Builder is now Faraday::RackBuilder.
/Users/Rafi/Desktop/my_ebooks/bots.rb:13:in `<top (required)>': undefined local variable or method `“raf_ebooks”' for main:Object (NameError)
    from run.rb:33:in `require_relative'
    from run.rb:33:in `<main>'

Solution

  • You have curly quotation marks that Ruby doesn't pick up. This happens when you use word processors that try to get fancy.

    TWITTER_USERNAME = “raf_ebooks" # Ebooks account username
    TEXT_MODEL_NAME = “raf_ebooks" # This should be the name of the text model
    

    Notice the broken syntax highlighting. They should be "normal" straight quotes:

    TWITTER_USERNAME = "raf_ebooks" # Ebooks account username
    TEXT_MODEL_NAME = "raf_ebooks" # This should be the name of the text model
    

    Much better.

    Get yourself a decent editor. TextEdit is not suitable for coding. TextMate and Sublime Text are popular commercial editors. GitHub's Atom is a free editor, pretty nice too.