前提・実現したいこと
現在rails 学習のためインスタグラムに似たwebサイトを作っています。その中で投稿された画像をクリックした時、その画像に関する情報をモーダルウィンドウで表示させる機能を着けようと考えているのですが、うまく実装できなかったので質問させていただきました。
該当のソースコード
<div class=row> <% @microposts.each do|micropost|%> <div class=col-4> <%= image_tag (micropost.picture.url,options = {class:'img-fluid' , data-toggle: 'modal' , data-target: '#microposts_show'})%> ※モーダルウインドウで表示させたい内容(パーシャルからもってきたいです)↓ <div class = "modal" id= "microposts_show" tabindex = '-1' role="dialog"> <div class = "modal-body"><%=render "microposts/show" %></div> </div> ※ <h4><%= micropost.title%></h4> </div> <% end %> <%= will_paginate @microposts %> </div>
###エラーコード
/home/ec2-user/environment/sub_task_app/app/views/users/show.html.erb:27: syntax error, unexpected ':', expecting => ...lass: 'img-fluid', data-toggle: 'modal',data-target: '#micro... ... ^ /home/ec2user/environment/sub_task_app/app/views/users/ show.html.erb:27: syntax error, unexpected ',', expecting ')' ...g-fluid', data-toggle: 'modal',data-target: '#microposts_sho... ... ^ /home/ec2- user/environment/sub_task_app/app/views/users/show.html.erb:27: syntax error, unexpected ':', expecting ')' ...ta-toggle: 'modal',data-target: '#microposts_show'}));@outpu... ... ^ /home/ec2-user/environment/sub_task_app/app/views/users/show.html.erb:27: syntax error, unexpected '}', expecting ')' ...ata-target: '#microposts_show'}));@output_buffer.safe_append... ... ^ /home/ec2- user/environment/sub_task_app/app/views/users/show.html.erb:33: syntax error, unexpected end, expecting ')' '.freeze; end ^~~ /home/ec2- user/environment/sub_task_app/app/views/users/show.html.erb:37: syntax error, unexpected ensure, expecting ')' ensure ^~~~~~ /home/ec2- user/environment/sub_task_app/app/views/users/show.html.erb:39: syntax error, unexpected end, expecting ')' end ^~~
##サーバーのエラー反応
app/views/users/show.html.erb:27: syntax error, unexpected ':', expecting =>
app/views/users/show.html.erb:27: syntax error, unexpected ',', expecting ')'
app/views/users/show.html.erb:27: syntax error, unexpected ':', expecting ')'
app/views/users/show.html.erb:27: syntax error, unexpected '}', expecting ')'
app/views/users/show.html.erb:33: syntax error, unexpected end, expecting ')'
app/views/users/show.html.erb:37: syntax error, unexpected ensure, expecting ')'
app/views/users/show.html.erb:39: syntax error, unexpected end, expecting ')'
試したこと
書籍やグーグルで似た事例を探し、いくつか試したのですがうまく行かず、原因が特定できませんでした。
つまらないミスが原因かもしれませんがどうかよろしくお願いします
補足情報(FW/ツールのバージョンなど)
rails 5.1.6 ruby 2.6.3 bootstrap 4.3.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/09/17 11:10 編集
2019/09/17 11:09