我有一个用户模型,其中 has_many :portfolios 和每个 Portfolio has_many :pictures。我的路线如下所示:
resources :users do
resources :portfolios do
resources :pictures
end
end
然后我尝试像这样创建一个新的投资组合:
<%= link_to "new portfolio...", new_user_portfolio_path(current_user) %>
使用这样的表格:
<%= form_for [current_user, @portfolio], html: { class: "form_settings" } do |f| %>
...
<% end %>
但是当我点击“新的投资组合......”时,我的 URL/users/12/portfolios/new
显示并出现此错误:
No route matches {:action=>"show", :controller=>"portfolios", :user_id=>#<User id: 12, name: "michael", password_digest: "d787f56b080945c1ec0b3343cbf962ca427bb8ef", remember_token: "dL4nPlt0E5azUMemNIvkdg", admin: false, created_at: "2013-03-03 01:18:19", updated_at: "2013-03-03 19:56:28">, :id=>#<Portfolio id: nil, user_id: 12, name: nil, created_at: nil, updated_at: nil>}