0

I am working in the following code. It is from the project 8agentball available in github (https://github.com/thinkpixellab/agent8ball).

I am a beginner in Ruby and Rails(started learning today), and I get an error when I try to execute it. I searched in the internet for over 4 hours and did not find anything.

- uncompiled = Rails.env == 'development' && params.has_key?('uncompiled')
- content_for :header do
  = game_js(uncompiled)
    %link{:rel => 'canonical', :href => 'http://agent8ball.com'}
    %a#fork_me{:href => "https://github.com/thinkpixellab/agent8ball"}
    %img{:alt => "Fork me on GitHub", :src => "http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"}

- if Rails.env == 'development'
  - if(uncompiled)
    = link_to "Uncompiled", root_path, :id => 'debug', :title => 'Go to compiled version'
  - else
    = link_to "Compiled", '/?uncompiled', :id => 'debug', :title => 'Go to uncompiled version'

And I get this error:

Showing /Users/user/Documents/61/v4/agent8ball-master/app/views/main/index.haml where line #xx raised:

/Users/user/Documents/61/v4/agent8ball-master/app/views/main/index.haml:xx: syntax error, unexpected keyword_ensure, expecting end-of-input

I tried indenting code, tried putting - end after if/else and/or do but to no use.

Any idea?

Thank you

py_master
  • 1
  • 1
  • 2
    Try adjusting your identation in lines 4-6; use the same indentation as `= game_js`. – Wikiti Jun 11 '16 at 16:29
  • 1
    You'll find it easier to solve this sort of problem if you can reduce it to a minimal example - try deleting portions of your code: if the problem persists, with the same error, then the error wasn't in the deleted code. Repeat until you have a short sample with the problem. – Frederick Cheung Jun 11 '16 at 16:30
  • @Wikiti tried that, brings another error. – py_master Jun 11 '16 at 16:34
  • @FrederickCheung I have done that, i removed part by part from the end until line 14 and the error is the same as the one I wrote in the question. – py_master Jun 11 '16 at 16:34
  • Great - that minimal example should be what is in your question. – Frederick Cheung Jun 11 '16 at 16:35
  • @FrederickCheung I removed the rest. – py_master Jun 11 '16 at 16:37
  • @py_master What's the other error? – Wikiti Jun 11 '16 at 16:38
  • @Wikiti "no implicit conversion of nil into String" – py_master Jun 11 '16 at 16:40
  • @py_master Can I get a backtrace of that error? Also, it would be interesting to see how `game_js` is implemented. Is that a library helper? – Wikiti Jun 11 '16 at 16:41
  • @Wikiti How do I get a backtrace of the error? It is a function almost 15 lines long. – py_master Jun 11 '16 at 16:48
  • @py_master In the rails console, after a http 500 error (for example, this render error), a backtrace of the error should be printed. If it's not showing anything, try something like [`this`](http://stackoverflow.com/questions/380744/how-to-force-ruby-to-show-full-stack-trace). Also, maybe `game_js` is trying to concatenate a `nil` value with a string. With the code, we may resolve your issue. – Wikiti Jun 11 '16 at 16:52
  • It's probably a good idea to get some of the Ruby fundamentals down before you learn Rails. Maybe try Sinatra, also. – max pleaner Jun 11 '16 at 20:10

0 Answers0