我有我的索引(Twit模型,twits控制器)的推文列表旁邊的複選框。我想要做的是將檢查過的推文保存到其他模型(重新發布模型,重新發布控制器)。Rails - 從索引保存項目,並將其寫入一個新的模型
Repost模型將具有與Twit相同的屬性。我只想從我的索引視圖中選擇特定的推文並將它們保存到Repost模型中。
這是我的觀點:
<%= form_tag reposts_path do %>
<ul>
<% @twits.each do |twit| %>
<li>
<%= twit.like %> likes
<%= check_box_tag "repost_twit_#{twit.id}" %> -
<%= link_to twit_path(twit) do %>
<i class="glyphicon glyphicon-eye-open"></i>
<% end %> -
<%= link_to twit_path(twit), method: :delete do %>
<i class="glyphicon glyphicon-trash"></i>
<% end %>
</li>
<% end %>
</ul>
<ul>
<li></li>
</ul>
<%= submit_tag "Add to your Repost library", class: "btn btn-primary" %>
我有邏輯,我成功了我的Rails控制檯內這樣做,但我不能在應用程序內做到這一點...這將是這樣的Repost.create(like:Twit.first.like)
我明顯錯過了一些東西。謝謝你的幫助。
當您提交此表單時,日誌中顯示的請求參數是什麼。 – Bijendra
您好@Bijendra,我有這條消息=>沒有找到RepostsController模板#創建,渲染頭:no_content我明白,我的查看新/創建丟失,但我想從我的TwitController#索引 – Eric