3
這些都是相關機型:嵌套路線顯示所有記錄而不是實例記錄
class Repository < ActiveRecord::Base
has_many :quizzes, :dependent => :destroy
has_one :key, :dependent => :destroy
accepts_nested_attributes_for :key, :quizzes
end
class Quiz < ActiveRecord::Base
belongs_to :repository
has_many :topics, :dependent => :destroy
accepts_nested_attributes_for :topics
end
這是我的路線:
GqAPI::Application.routes.draw do
resources :repositories do
resources :quizzes
end
resources :quizzes
resources :keys
resources :topics
resources :questions
end
當我嘗試這個配置我得到的所有的測驗數據庫,而不僅僅是我在嘗試訪問/ repositories/1/quizzes時指定的ID
有關爲什麼?非常感謝您的時間
謝謝,這個伎倆。但是,您的建議讓我意識到我正在做這一切都是錯誤的......再次感謝! – tylermauthe 2012-04-11 00:36:00
很高興我能夠幫助。這是一個學習過程。可能想在http://codeschool.com查看Rails for Zombies。當我第一次出發時,我發現它非常有用。 – ardavis 2012-04-11 00:37:52
謝謝,我正在查看它! – tylermauthe 2012-04-11 00:56:21