我有以下关联的2个模型。
Goal.rb
has_one :progress
Run Code Online (Sandbox Code Playgroud)
progress.rb
belongs_to :goal
Run Code Online (Sandbox Code Playgroud)
在目标索引页面中,我有一个链接,该链接应该为该特定目标编辑进度记录,但是我找不到它来找到进度记录的正确记录ID。我的link_to代码如下。它将传递目标ID,而不是正确的进度ID。
app / view / goals / index.html.erb
<%= link_to 'Progress', edit_progress_path(goal) %>
Run Code Online (Sandbox Code Playgroud)
我应该怎么做。
谢谢。
干杯,阿兹伦
我喜欢使用Rails的“魔术”:
<%= link_to 'Progress', [:edit, goal.progress] %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3988 次 |
| 最近记录: |