使用breadcrumbs update_attributes

时间:2014-07-29 09:16:55

标签: ruby-on-rails twitter-bootstrap

我的模型中有状态枚举:

enum status: [ :draft, :pending, :accepted, :reoffered, :rejected ]

我正在从这样的形式改变它:

<%= f.input :status, as: :select, collection: Offer.statuses.keys.to_a %>

您是否可以使用可点击的面包屑向我提示如何直接从索引视图更改状态?

谢谢!

1 个答案:

答案 0 :(得分:0)

我让它像以下一样工作:

<div class="breadcrumb">
          <li>
            <%= link_to "Draft", offer_path(:id => offer.id, "offer[status]" => "draft"), method: :put, :action => "update" %>
            <span class="divider">/</span>
          </li>
          <li>
            <%= link_to "Pending", offer_path(:id => offer.id, "offer[status]" => "pending"), method: :put, :action => "update" %>
            <span class="divider">/</span>
          </li>
          <li>
            <%= link_to "Accepted", offer_path(:id => offer.id, "offer[status]" => "accepted"), method: :put, :action => "update" %>
            <span class="divider">/</span>
          </li>

</div>