0

我有以下路线。我希望应用程序的结构保持不变(一个控制器具有多种功能),但我想让路由文件看起来更合理且易于扩展。

get 'splunk/ocd/:order_id' => "splunk#order_collection_details"
get 'splunk/ord/:order_id' => "splunk#order_request_details"
get 'splunk/ord_ar/:request_id' => "splunk#ord_associated_requests"
get 'splunk/ord_ad/:user_id/:deal_option_id' => "splunk#ord_additional_details"
get 'splunk/avatax_logs/:order_id' => "splunk#avatax_logs"
get 'splunk/billing_updates/:billing_record_id' => "splunk#billing_updates"
get 'splunk/cc_storage_details/:billing_record_id' => "splunk#cc_storage_details"
4

1 回答 1

1

我同意@MikeBrant 的观点,似乎真的不需要重构这个,但如果你真的想,我可能会尝试这样的事情 -

controller :splunk do
  get 'splunk/ocd/:order_id' => :order_collection_details
  get 'splunk/ord/:order_id' => :order_request_details
  get 'splunk/ord_ar/:request_id' => :ord_associated_requests
  get 'splunk/ord_ad/:user_id/:deal_option_id' => :ord_additional_details
  get 'splunk/avatax_logs/:order_id' => :avatax_logs
  get 'splunk/billing_updates/:billing_record_id' => :billing_updates
  get 'splunk/cc_storage_details/:billing_record_id' => :cc_storage_details
end

它更有条理,更容易阅读,但如果你的整个应用程序将围绕一个控制器,我不确定我是否看到了这种需要。

于 2012-08-06T22:12:30.960 回答