簡體   English   中英

如何在Ruby on Rails中使用具有嵌套關聯的Best in place

[英]How to use Best in place with nested association in ruby on rails

應用程序/模型/ user.rb

has_one :user_detail

應用程序/模型/ user_detail.rb

belongs_to :user

unit_numberunit_number的屬性。

我想在用戶顯示頁面中內聯編輯此屬性。但是我不知道該怎么做。

<%= best_in_place user, :unit_number %>

它給出了一個錯誤,我該怎么辦?

請嘗試以下方法:

<%= best_in_place user.user_detail, :unit_number, path: user_detail_path %>

其中user_detail_path是更新用戶詳細信息路徑。 您必須從routes.rb定義此路由。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM