Hi folks!

Im currently trying to generate diagrams with a js lib and rails. It
doesn't work, though, since I can't figure out how to embed ruby code to
supply the diagrams with data. My editor highlights the ruby code
weirdly,
too, with I take as a hint for wrong ruby syntax.
The diagrams work if I use the pure-js sample data, but it REALLY dont
want to input data sets with 200 items by hand.

The snippet in question is this one, it lives in an .html.erb file:

  var hour = [
     <% @raw.each do |raw| %>
     [ <%= if raw.status == "aufgewacht" %>
         <%= Time.parse(raw.timestamp).wday.to_json %>,
         <%= raw.timestamp[15,2].to_json %>
       <% end %> ],
     <% end %>
   ];
(yeah, pretty ugly)

Some error messages; line 20 contains the "if"-conditional
.../app/views/processed_data/_scatter.html.erb:20: syntax error,
unexpected ')', expecting keyword_then or ';' or '\n'
...nd= ( if raw.status == "woke" );@output_buffer.safe_concat('

app/views/processed_data/_scatter.html.erb:23: syntax error, unexpected
keyword_end, expecting ')'
...ffer.safe_concat(' '); end ;@output_buffer.safe_concat(...


Does anyone know how to do this?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0f8c516c5d0136e350659aa7ea4fba63%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Marco Antonio Almeida at Jun 5, 2016 at 11:04 pm
    Hi Rynn,
    On Mon, Jun 6, 2016 at 12:15 AM Rynn Steinbolt wrote:

    Hi folks!

    Im currently trying to generate diagrams with a js lib and rails. It
    doesn't work, though, since I can't figure out how to embed ruby code to
    supply the diagrams with data. My editor highlights the ruby code
    weirdly,
    too, with I take as a hint for wrong ruby syntax.
    The diagrams work if I use the pure-js sample data, but it REALLY dont
    want to input data sets with 200 items by hand.

    The snippet in question is this one, it lives in an .html.erb file:

    var hour = [
    <% @raw.each do |raw| %>
    [ <%= if raw.status == "aufgewacht" %>
    It seems that your problem is here. You don't want to output the if
    condition so you should actually have:

    <% if raw.status == "aufgewacht" %>

    <%= Time.parse(raw.timestamp).wday.to_json %>,
    <%= raw.timestamp[15,2].to_json %>
    <% end %> ],
    <% end %>
    ];
    (yeah, pretty ugly)

    Some error messages; line 20 contains the "if"-conditional
    .../app/views/processed_data/_scatter.html.erb:20: syntax error,
    unexpected ')', expecting keyword_then or ';' or '\n'
    ...nd= ( if raw.status == "woke" );@output_buffer.safe_concat('

    app/views/processed_data/_scatter.html.erb:23: syntax error, unexpected
    keyword_end, expecting ')'
    ...ffer.safe_concat(' '); end ;@output_buffer.safe_concat(...


    Does anyone know how to do this?

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/rubyonrails-talk/0f8c516c5d0136e350659aa7ea4fba63%40ruby-forum.com
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACMkcE7fvAK-2_%2B5M6kjkPi1TC1r9%2BtxVYxphLYwouQmGz%2BVHQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rynn Steinbolt at Jun 5, 2016 at 11:35 pm

    Marco Antonio Almeida wrote in post #1183823:
    Hi Rynn,
    On Mon, Jun 6, 2016 at 12:15 AM Rynn Steinbolt wrote:

    The snippet in question is this one, it lives in an .html.erb file:

    var hour = [
    <% @raw.each do |raw| %>
    [ <%= if raw.status == "aufgewacht" %>
    It seems that your problem is here. You don't want to output the if
    condition so you should actually have:

    <% if raw.status == "aufgewacht" %>
    Thank you! That does indeed get rid of the error messages. I wonder how
    i missed this.
    However, the code still doesnt work - there is no data displayed.

    Maybe the syntax highlighting makes it a bit clearer. Compare the two
    attached snippets, one with the js/erb code (with a working var hour
    below it, to demontrate that the js is (probably) not the problem, and
    some reguler embedded ruby without js.

    Attachments:
    http://www.ruby-forum.com/attachment/11367/Auswahl_004.jpg
    http://www.ruby-forum.com/attachment/11368/Auswahl_006.jpg


    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1c77ef7500ca72a3d39fdfbaf4f3a2d3%40ruby-forum.com.
    For more options, visit https://groups.google.com/d/optout.
  • Walter Lee Davis at Jun 6, 2016 at 12:19 am

    On Jun 5, 2016, at 7:35 PM, Rynn Steinbolt wrote:

    Marco Antonio Almeida wrote in post #1183823:
    Hi Rynn,

    On Mon, Jun 6, 2016 at 12:15 AM Rynn Steinbolt <lists@ruby-forum.com>
    wrote:
    The snippet in question is this one, it lives in an .html.erb file:

    var hour = [
    <% @raw.each do |raw| %>
    [ <%= if raw.status == "aufgewacht" %>
    It seems that your problem is here. You don't want to output the if
    condition so you should actually have:

    <% if raw.status == "aufgewacht" %>
    Thank you! That does indeed get rid of the error messages. I wonder how
    i missed this.
    However, the code still doesnt work - there is no data displayed.

    Maybe the syntax highlighting makes it a bit clearer. Compare the two
    attached snippets, one with the js/erb code (with a working var hour
    below it, to demontrate that the js is (probably) not the problem, and
    some reguler embedded ruby without js.

    Attachments:
    http://www.ruby-forum.com/attachment/11367/Auswahl_004.jpg
    http://www.ruby-forum.com/attachment/11368/Auswahl_006.jpg
    You may be getting tripped up by the fact that raw() is a view helper method, and you are using it within your block as a local variable. Try a different word, and see if that makes any difference.

    Walter
    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1c77ef7500ca72a3d39fdfbaf4f3a2d3%40ruby-forum.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/B0BEAAAB-389F-4922-AD3B-49B77B50B787%40wdstudio.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rynn Steinbolt at Jun 6, 2016 at 2:57 pm

    Walter Davis wrote in post #1183825:
    var hour = [
    i missed this.
    You may be getting tripped up by the fact that raw() is a view helper
    method, and you are using it within your block as a local variable. Try
    a different word, and see if that makes any difference.

    Walter
    Thanks for your input!

    Unfortunately it didnt solve my problem, but I finally figured it out:

    I had a newline character appended to my status variable, so raw.status
    could never equal "aufgewacht". It does, though, with raw.status.chomp!

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e15237d929033d7cbc07378050381d40%40ruby-forum.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJun 5, '16 at 10:14p
activeJun 6, '16 at 2:57p
posts5
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase