1

The relevant code causing the problem seems to be this from my view:

<input type="checkbox" id=<%= "#{a[0]}#{ndx}" -%> class="toggle" />
        <label for=<%= "#{a[0]}#{ndx}" -%> class="popup-label">

This throws the following error in the Heroku logs:

SyntaxError - /app/views/index.erb:25: syntax error, unexpected ')'
2017-03-17T06:30:26.877056+00:00 app[web.1]: ...buf.concat(( "#{a[0]}#{ndx}" -).to_s); @_out_buf.concat " cl...
2017-03-17T06:30:26.877061+00:00 app[web.1]: /app/views/index.erb:26: syntax error, unexpected ')'
2017-03-17T06:30:26.877057+00:00 app[web.1]: ...                               ^
2017-03-17T06:30:26.877061+00:00 app[web.1]: ...buf.concat(( "#{a[0]}#{ndx}" -).to_s); @_out_buf.concat " cl...

I initially thought it might be the difference between using WEBrick and Puma, but I swapped them and found no difference. Suggestions?

stevensonmt
  • 702
  • 1
  • 6
  • 19
  • Line numbers in ERB error messages do not necessarily point to the line in which the error is originated. But to the line in which ERB notice that the structure is invalid. The syntax error itself (in this case probably a orphan `(`) is found before that line. Please post your the full view. Please tell what implementation of ERB you are using. – spickermann Mar 17 '17 at 06:53
  • I'm not sure I understand. What do you mean by "what implementation of ERB"? Also, the syntax error apparently arose from the - in the closing of the erb statement. – stevensonmt Mar 17 '17 at 07:08
  • It seems to me that you are running different versions of gems locally and on the server. Are you using `bundler`? – froderik Mar 17 '17 at 07:44
  • `ERB` is some kind of definition or language how to generate HTML from Ruby with `<% %>` tags. There are different implementations of `ERB`: The original version from the Ruby Standard Lib, but also alternatives like Erubis, Erubi that are faster, but might have a slightly different behavior. Especially the minus in `-%>` is not needed on Erubis and Erubis. When you use different implementation in development and on production then that might explain that you get errors on one environment but not on the other. – spickermann Mar 17 '17 at 07:49
  • @froderik -- I am using bundler. Gem versions are the same, not sure what in the error suggests otherwise. – stevensonmt Mar 17 '17 at 13:20
  • @spickermann -- I see. Unless Sinatra implements a different version, it is the version from the standard lib. I do not know if Heroku defaults to a different implementation, but this app is very simple and does not have different environment configs for production and development. – stevensonmt Mar 17 '17 at 13:22

1 Answers1

0

Please try the below

<input type="checkbox" id="<%= a[0].to_s + ndx.to_s  %>" class="toggle" />
<label for="<%= a[0].to_s + ndx.to_s %>" class="popup-label">
Rajarshi Das
  • 11,778
  • 6
  • 46
  • 74
  • Actually all that was necessary was removing the "-" from "-%>". Having a different issue now though. It launches but does not render the same as on local. – stevensonmt Mar 17 '17 at 06:55
  • but does not render the same as on local. what does it mean ? you are concatenating `ndx` and `a[0]` on your code I did the same – Rajarshi Das Mar 17 '17 at 06:58
  • I mean when I solved this problem I found a separate problem. The string conversion was not the issue. Your method for that works fine, but the issue was the -%> in my original code. The new problem has to do with CSS. I'm using the checkbox hack to create a popup with additional information. It works beautifully here but heroku doesn't hide the div when the checkbox is unchecked. It also doesn't hide the checkbox as I want the label to trigger the popup. – stevensonmt Mar 17 '17 at 07:07
  • http://stackoverflow.com/questions/998979/difference-between-and-in-rails this is the difference between %> and -%> – Rajarshi Das Mar 17 '17 at 07:10