Note that there are some explanatory texts on larger screens.

plurals
  1. POUnexpected 'LOGIC' in coffeescript template
    primarykey
    data
    text
    <p>Having this code in a view partial of type .js.coffee (it's being rendered as a view, not as an asset) :</p> <pre><code>&lt;% if @followed_car_ids.present? %&gt; for car_id_and_path in &lt;%= @followed_car_ids_and_paths.to_json %&gt; toggle_follow(car_id_and_path[0], true, car_id_and_path[1]) &lt;% end %&gt; </code></pre> <p>In the controller:</p> <pre><code>@followed_car_ids_and_paths = @followed_cars.map{|car| [car.id, url_for(current_user.car_subscriptions.find_by_car_id(car))]} </code></pre> <p>Note that it doesn't matter if I put the map (or collect) in the view. Doesn't work either if I put a simple string instead of <code>url_for(...</code>.</p> <p>It gives this error:</p> <pre><code>ActionView::Template::Error (Error: Parse error on line 1: Unexpected 'LOGIC'): 1: &lt;% if @followed_car_ids.present? %&gt; 2: for car_id_and_path in &lt;%= @followed_car_ids_and_paths.to_json %&gt; 3: toggle_follow(car_id_and_path[0], true, car_id_and_path[1]) 4: &lt;% end %&gt; app/views/general_ajax/_update_followed_cars.js.coffee:1:in `_app_views_general_ajax__update_followed_cars_js_coffee__3478461849674996439_70355260673980' </code></pre> <p>When I remove the <code>=</code> from <code>&lt;%=</code> on line 2 and add some kind of dummy array before the error stops:</p> <pre><code>for car_id_and_path in [1,2,3] &lt;% @followed_car_ids_and_paths.to_json %&gt; </code></pre> <p>The error doesn't occur if I use a flat array (not doubled with map):</p> <pre><code>for car_id_and_path in &lt;%= @followed_car_ids %&gt; </code></pre> <p>Neither when it's like this:</p> <pre><code>for car_id_and_path in [[1, 'a'],[2, 'b'],[3, 'c']] </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload