完整的代码段-6ren">
gpt4 book ai didi

ruby-on-rails - 找不到: syntax error, unexpected '>' in ROR app的原因

转载 作者:行者123 更新时间:2023-12-03 08:27:30 27 4
gpt4 key购买 nike

好的,这可能是愚蠢的,但是我整夜都在努力寻找代码中此错误的原因,但是没有运气。

我的最后一个选择是看看您的眼睛是否比我的眼睛更好。

我在下面的行(第68行)中收到此错误:

   <%= image_tag image_product.image.url(:medium), class: "img-responsive", id: "<%= index == 0 ? 'zoom_05' : '' %>" %>

完整的代码段如下:
 <div class='carousel-inner '>
<% @product.images.each_with_index do |image_product, index| %>
<div class=<%= index == 0 ? 'item active' : '' %> >
<%= image_tag image_product.image.url(:medium), class: "img-responsive", id: "<%= index == 0 ? 'zoom_05' : '' %>" %>
</div>
<% end %>

<script>
$("#zoom_05").elevateZoom({ zoomType : "inner", cursor: "crosshair" });
</script>
</div>
<!-- sag sol -->
<a class='left carousel-control' href='#carousel-custom' data-slide='prev'>
<span class='glyphicon glyphicon-chevron-left'></span>
</a>
<a class='right carousel-control' href='#carousel-custom' data-slide='next'>
<span class='glyphicon glyphicon-chevron-right'></span>
</a>
</div>

以及完整的错误消息:
 syntax error, unexpected '>'
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:74: unknown regexp options - crpt
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:75: syntax error, unexpected '<'
</div>
^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:78: unknown regexp options - pa
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:79: syntax error, unexpected '<'
</a>
^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:81: unknown regexp options - pa
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:82: syntax error, unexpected '<'
</a>
^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:83: unknown regexp options - dv
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:84: syntax error, unexpected '<'
<!-- thumb -->
^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:84: syntax error, unexpected unary-, expecting keyword_do or '{' or '('
<!-- thumb -->
^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:86: syntax error, unexpected keyword_do_LAMBDA
...oduct.images.each_with_index do |image_product, index|
... ^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:86: syntax error, unexpected '|', expecting '='
...index do |image_product, index|
... ^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:90: syntax error, unexpected keyword_end, expecting ')'
'.freeze; end
^
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:135: syntax error, unexpected keyword_ensure, expecting ')'
/Users/dadi/Documents/Vefir/stores/hlinreykdal/app/views/products/show.html.erb:137: syntax error, unexpected keyword_end, expecting ')'

最佳答案

您不能嵌套<% %>,而需要使用字符串插值,如下所示:

<%= image_tag image_product.image.url(:medium), class: "img-responsive", id: "#{index == 0 ? 'zoom_05' : ''}" %>

尽管由于您已经在使用ruby代码,所以根本不需要任何插值,所以您可以执行以下操作:
<%= image_tag image_product.image.url(:medium), class: "img-responsive", id: index == 0 ? "zoom_05" : "" %>

关于ruby-on-rails - 找不到: syntax error, unexpected '>' in ROR app的原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45517173/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com