[英]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_number
是unit_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.