0

So far I have my routes like this: ( out of learning purposes I am curious to get it working with nested resources technique, but if you think this will get too complicated please feel free to suggest any other way of routing technique too)

  resources :management, only: [:show] do
    resources :report, only: [:show], controller: 'report' do
      member do
         # hmm what to write in here?!
      end
    end
  end

my GOAL is to have a URL like this:

/managment/SOME_ID_WE_PASS_/report
/managment/1/report

But still can't figure out how exactly to write that route? Can you please take a look?

4

1 に答える 1

1

ネストされたリソースは必要ありません。

resources :crowd_management, only: [:show] do
  get :exec_report, on: :member
end

それは以下を生成します:

/crowd_management/:idマッピング先CrowdManagementController#show /crowd_management/:id/exec_reportマッピング先CrowdManagementController#exec_report

ヘルパー メソッドは次のとおりです。

crowd_management_path
exec_report_crowd_management_path

rake routesすべてのルートの詳細なリストを実行できます。

于 2013-02-27T04:03:46.770 に答える