現状
星評価機能を感想投稿サイトに実装しました。
しかし、投稿をクリックしても発火せず、ターミナルにも情報が保存された文章は走っていません。
以下が、投稿ボタンのコードです。
Jquery
1 <div class="col-md-3"> 2 <% if book.errors.any? %> 3 <%= book.errors.count %>error 4 <ul> 5 <% book.errors.full_messages.each do |message| %> 6 <li><%= message %></li> 7 <% end %> 8 </ul> 9 <% end %> 10 11 <h2>User info</h2> 12 <%= image_tag user.get_profile_image(100,100) %> 13 <table class="table"> 14 <tbody> 15 <tr></tr> 16 <tr> 17 <th>name</th> 18 <th><%= user.name %></th> 19 </tr> 20 <tr> 21 <th>introduction</th> 22 <th><%= user.introduction %></th> 23 <th></th> 24 </tr> 25 </tbody> 26 </table> 27 <% if user.name != "guestuser" %> 28 <div class="row"> 29 <%= link_to edit_user_path(user),class: "btn btn-outline-secondary btn-block edit_user_11572" do %> 30 <i class="fas fa-user-cog"></i> 31 <% end %> 32 </div> 33 34 <h2 class="mt-3">New book</h2> 35 <%= form_with model: @book, local: true do |f| %> 36 <div class="form-group"> 37 <lavel for="book_title">Title</lavel></br> 38 <%= f.text_field :title %> 39 </div> 40 41 <div class="form-group"> 42 <lavel for="book_body">Opinion</lavel></br> 43 <%= f.text_area :body %></br> 44 </div> 45 <%= form_with(model: @book, local: true) do |f| %> 46 <div class="star-form-group" id="star1"> 47 <%= f.label :star,'Rate', class:'star-title' %> 48 </div> 49 <% end %> 50 <script> 51 $('#star1').raty({ 52 size : 38, 53 starOff: '<%= asset_path('star-off.png') %>', 54 starOn : '<%= asset_path('star-on.png') %>', 55 starHalf: '<%= asset_path('star-half.png') %>', 56 scoreName: 'book[star]', 57 half: true, 58 }); 59 </script></br> 60 <%= f.submit "Create Book",class: "btn btn-success" %> 61 <% end %> 62 <% end %>
推測
恐らく、星評価機能実装前は投稿出来ていたため、
タグのかこっている範囲がおかしいのかなと考え、試してみましたがうまくいきませんでした。
分かる方、ご教授いただければ幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2022/06/07 04:27
2022/06/07 05:37