0

私の routes.rb ファイルには、次のリソースがあります。

resources :educations do
  resources :semesters do
    resources :module_assignments do
      resources :module_exams do
        resources :module_marks
      end
    end
  end
end

この URL ヘルパーを生成するもの:

logonname_module_assignment_module_exams_path   GET /:student/module_assignments/:module_assignment_id/module_exams(.:format)   module_exams#index

これを短くする方法はありますか?同じコントローラーと同じアクションにリダイレクトする必要があります。それ以外の

logonname_module_assignment_module_exams_path

私は次のようなものを好むだろう

module_exams_path

これを解決する方法はありますか?表示パスだけでなく、このようなすべての URL ヘルパー (index、new、edit、show など) が必要です。

4

1 に答える 1

2

それほど深くネストする必要はありません

私は個人的に深さ 2 までしか行っていません。これにより、維持が容易になります。

しかし、それは質問に答えません。または多分そうです。

あなたのセットアップで。次のようなことができます:

match '/:student/module_assignments/:module_assignment_id/module_exams(.:format)' => 'module_exams#index', :as => :module_exams

これによりmodule_exams_path、ヘルパーとして提供されます。

于 2015-06-29T14:38:32.593 に答える