次のルートがあります。
resources :businesses, only: [:show, :index, :new, :create] do
resources :pledge_drives
end
これにより、以下が作成されます。
% rake routes | grep pledge
business_pledge_drives GET /businesses/:business_id/pledge_drives(.:format) pledge_drives#index
POST /businesses/:business_id/pledge_drives(.:format) pledge_drives#create
new_business_pledge_drife GET /businesses/:business_id/pledge_drives/new(.:format) pledge_drives#new
edit_business_pledge_drife GET /businesses/:business_id/pledge_drives/:id/edit(.:format) pledge_drives#edit
business_pledge_drife GET /businesses/:business_id/pledge_drives/:id(.:format) pledge_drives#show
PUT /businesses/:business_id/pledge_drives/:id(.:format) pledge_drives#update
DELETE /businesses/:business_id/pledge_drives/:id(.:format) pledge_drives#destroy
URL ヘルパー メソッドを呼び出したくありませんbusiness_pledge_drife_path
。の特異化でRailsを修正するにはどうすればよいdrives
ですか? 実際の URL は問題ありません。
編集: この答えは正しかった。config/initializers/inflections.rb に以下を追加しました:
ActiveSupport::Inflector.inflections do |inflect|
inflect.plural 'drive', 'drives'
inflect.singular 'drives', 'drive'
end
今私のルートは次のとおりです。
business_pledge_drives GET /businesses/:business_id/pledge_drives(.:format) pledge_drives#index
POST /businesses/:business_id/pledge_drives(.:format) pledge_drives#create
new_business_pledge_drive GET /businesses/:business_id/pledge_drives/new(.:format) pledge_drives#new
edit_business_pledge_drive GET /businesses/:business_id/pledge_drives/:id/edit(.:format) pledge_drives#edit
business_pledge_drive GET /businesses/:business_id/pledge_drives/:id(.:format) pledge_drives#show
PUT /businesses/:business_id/pledge_drives/:id(.:format) pledge_drives#update
DELETE /businesses/:business_id/pledge_drives/:id(.:format) pledge_drives#destroy