2013-01-12 32 views
0

我有一个嵌套的资源:我的钢轨嵌套模型数据如何保存没有ID?

resources :users do 
    resources :cust_uploads 
    end 

上传制成后,我可以将用户的索引页面下查看它们的列表:

<% @user.cust_uploads.each do |up| %> 
    <li><%= up.name %></li> 
    <% end %> 

但是当我去:/用户/ 3/cust_uploads/1我找不到记录错误:找不到id = 1的CustUpload。我没有妥善保存到DB吗?

任何想法发生了什么或我如何诊断?

架构没有ID列,但我认为这是自动的?

ActiveRecord::Schema.define(:version => 20130109001001) do 

    create_table "cust_uploads", :force => true do |t| 
    t.string "name" 
    t.string "cust_file_url" 
    t.datetime "created_at", :null => false 
    t.datetime "updated_at", :null => false 
    t.integer "user_id" 
    end 

    create_table "users", :force => true do |t| 
    t.string "email" 
    t.string "password_digest" 
    t.datetime "created_at",  :null => false 
    t.datetime "updated_at",  :null => false 
    end 

end 

回答

0

也许1不是创建模型的ID。尝试像这样打印它们,然后点击模型:

<% @user.cust_uploads.each do |up| %> 
    <li><%= link_to up.name, up %></li> 
<% end %> 
+0

深入挖掘时总是轻松解决方案!谢谢 – twinturbotom