我有以下路线。我希望应用程序的结构保持不变(一个控制器具有多个功能),但我想让路由文件看起来更合理,更容易扩展。
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"
答案 0 :(得分: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
它更有条理,更容易阅读,但如果你的整个应用程序将围绕一个控制器,我不确定我是否认为有必要。