gpt4 book ai didi

ruby-on-rails-3 - 带有嵌套资源的 Rails best_in_place gem

转载 作者:行者123 更新时间:2023-12-03 15:17:07 24 4
gpt4 key购买 nike

有谁知道使用带有 best_in_place gem 的嵌套资源是否可行(如果可行,语法是什么)?

我的 routes.rb 看起来像这样

resources :users do
resources :goals
end

我要编辑 :description目标的领域,但我认为的代码
<%= best_in_place [@user, @goal], :description %>

给出一个 NoMethodError 说
undefined method `description' for #<Array:0x20e0d28> 

使用
<%= best_in_place @goal, :description %>

给我一个未定义的方法错误也是因为没有 goal_path
我可以让 gem 毫无问题地用于@user(非嵌套资源)字段。

我正在运行 Rails 3.1.1、Ruby 1.9.2、best_in_place 1.0.4

最佳答案

我想到了。

我需要设置 path调用中的选项像这样

<%= best_in_place @goal, :description, :path => user_goal_path %>

它现在就像一个冠军!

关于ruby-on-rails-3 - 带有嵌套资源的 Rails best_in_place gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8779568/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com