海,
我尝试(并成功:-)构建了一个 rails 页面,我可以通过拖放来更新对象。我在表格中显示卡片,如果将它们放入列中,则会更新属性。到目前为止一切顺利,但不幸的是更新没有反映在卡中。我必须重新加载整个站点才能看到它(是的,我使用 <% = ... :-) 在我看到的日志中,部分呈现:
Started PUT "/cards/6" for 127.0.0.1 at 2013-03-21 16:55:42 +0100
Processing by CardsController#update as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"B+xkdpwcIcslidgHQPh+I1n+Qh/MxltM=", "card"=>{"user_id"=>"2", "state_id"=>"1"}, "id"=>"6"}
Card Load (0.1ms) SELECT "cards".* FROM "cards" WHERE "cards"."id" = ? LIMIT 1 [["id", "6"]]
(0.1ms) begin transaction
(0.2ms) UPDATE "cards" SET "user_id" = 2, "updated_at" = '2013-03-21 15:55:42.630330' WHERE "cards"."id" = 6
(3.2ms) commit transaction
State Load (0.1ms) SELECT "states".* FROM "states" WHERE "states"."id" = ? LIMIT 1 [["id", 1]]
Rendered cards/_card.html.erb (2.8ms)
Completed 200 OK in 9ms (Views: 3.5ms | ActiveRecord: 3.8ms)
但是在浏览器中,user_id 仍然是 3。所以我尝试也显示一个通知:
format.js {render @card, notice: "nanu"}
但是没有成功,通知也没有显示。
我的部分看起来像这样:
<%= form_for(@card, remote: true) do |f| %>
<div id="card_<%= @card.id %>" class="card_mini">
<h3><%= link_to @card.titel, edit_card_path(@card) %></h3>
<p><%= @card.beschreibung %></p>
<%= @card.user_id %> <!-- just to control the rendering -->
<%= f.text_field :user_id, type: "hidden" %>
<%= f.text_field :state_id, type: "hidden" %>
<div class="status"><%= @card.state_id ? State.find(@card.state_id).status : "--" %></div >
<%= link_to 'Destroy', @card, method: :delete, data: { confirm: 'Are you sure?' }, :class => "aktion" %>
</div>
<% end %>
你对我有什么提示吗?谢谢,S。