前提・実現したいこと
RubyonRailsでアプリを制作しています。
現在商品一覧画面を作っているのですが、
書いたコードにクラス名をつけると構文エラーになります。
クラス名を外すとエラー文は出ません。
なぜなのでしょうか?
発生している問題・エラーメッセージ
/vagrant/cs/app/views/items/index.html.erb:14: syntax error, unexpected tLABEL, expecting '=' ...fer.append=( item.genre, class:"genre" );@output_buffer.safe... ... ^~~~~~ /vagrant/cs/app/views/items/index.html.erb:15: syntax error, unexpected tL
該当のソースコード
【index.html.erb】 <% @items.each do |item| %> <%= attachment_image_tag item, :photo, :fill,800,800, format:'jpg', class:"item_photo" %> <%= item.genre, class:"genre_name" %>←該当部分 <%= item.brand, class:"brand_name" %>←該当部分 <%= item.season, class:"season_name" %>←該当部分 <% end %>
attachment_image_tagのクラス名は問題なく動いています。
なぜ下の3つだけクラス名をつけるとエラーになるのでしょうか?
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/28 06:25