Rails试图创建嵌套路由

Cat*_*ish 1 ruby routing ruby-on-rails ruby-on-rails-3

好吧,我正在拍摄这样的网址/applications/:application_id/jobseekers/new.我知道如果我生成2个脚手架(应用程序和求职者)我可以通过这样做使路线工作:

resources :applications do
  resources :jobseekers
end
Run Code Online (Sandbox Code Playgroud)

但我不需要为求职者提供完整的脚手架.我只需要一个new和create方法.

我如何编写我的路线,以便求职者#new和求职者#create方法有效?

我试过了

resources :applications do 
    get '/applications/:application_id/jobseekers/new', :to => 'jobseekers#new', :as => :new_application_jobseeker
    post '/applications/:application_id/jobseekers', :to => 'jobseekers#create'
  end
Run Code Online (Sandbox Code Playgroud)

但它给了我这个错误:

No route matches [GET] "/applications/3/jobseekers/new"
Run Code Online (Sandbox Code Playgroud)

当点击这个网址时:

localhost:3000/applications/3/jobseekers/new
Run Code Online (Sandbox Code Playgroud)

Sam*_*cey 5

您可以按如下方式指定所需的操作:

resources :applications do
  resources :jobseekers, :only=> [:new, :create]
end
Run Code Online (Sandbox Code Playgroud)