【问题标题】:How to call child model controller by using best_in_place gem如何使用 best_in_place gem 调用子模型控制器
【发布时间】:2015-01-02 11:12:54
【问题描述】:

我有一个ActiveRecord::BaseBox 那个has_many Cards 模型。

盒子show.html.erb里面有一些卡片是这样的:

views/boxes/show.html.erb

...
<% @cards.each do |card| %>
<%= best_in_place card, :front %>
<% end %>
...

我想使用best_in_place 来编辑值,但是它将请求发送到BoxesController 而不是CardsController 并最终出现错误AbstractController::ActionNotFound - The action 'update' could not be found for BoxesController:

如何使用best_in_place 指定控制器?

【问题讨论】:

    标签: ruby-on-rails ruby best-in-place


    【解决方案1】:

    您可以像这样指定路径:

    <%= best_in_place detail, :price, :display_as => :mk_bal, :classes => 'price_bind', :path => purchase_detail_path(@purchase, detail)%>
    

    【讨论】:

    • 根据警告:path 已弃用,所以我使用:url。还是谢谢!
    猜你喜欢
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-08
    • 2023-04-09
    相关资源
    最近更新 更多