0
這些都是我的路線:的Rails:嵌套資源問題
resources :forums, :shallow=>true do
resources :topics, :shallow=>true do
resources :posts
end
end
內topics/show.html.erb
我添加了一個形式來告別後(Post
就像是一個Topic
評論)
<%= form_for [@topic, @post] do |f| %>
<div class="field">
<%= f.label "content" %><br />
<%= f.text_area :content %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
問題模型Post
內的字段:topic_id
保持空白。 不應該自動獲取主題的ID嗎?
感謝
自動?不可以。顯示將表單數據保存到新模型實例的代碼。 – deefour