Ruby on rails 3.2 ruby rails如何获取命名路由的路径

Ruby on rails 3.2 ruby rails如何获取命名路由的路径,ruby-on-rails-3.2,routes,Ruby On Rails 3.2,Routes,如何获取命名路由的路径帮助器 routes.rb match 'report/monitor_id/:monitor_id/week_ending_date/:week_ending_date' => 'report#index' 如何获取命名路由的路径帮助器?当我做耙路时,前面什么都没有 /report/monitor_id/:monitor_id/week_ending_date/:week_ending_date(.:format) report#index 是否有

如何获取命名路由的路径帮助器

routes.rb

match 'report/monitor_id/:monitor_id/week_ending_date/:week_ending_date' => 'report#index'
如何获取命名路由的路径帮助器?当我做耙路时,前面什么都没有

/report/monitor_id/:monitor_id/week_ending_date/:week_ending_date(.:format)        report#index

是否有方法获取报告\u监视器\u id\u周\u结束日期\u路径(监视器\u id,周\u结束日期)?

您可以使用
为其命名:as
参数:

例:

应提供以下帮助:

logout_path
logout_url
不确定您希望将路线命名为什么,但可能类似于:

match 'report/monitor_id/:monitor_id/week_ending_date/:week_ending_date' => 'report#index', :as => :weekly_monitor_report
我相信这将为您提供帮助程序,允许按照路由定义中指定的顺序传递参数:

weekly_monitor_report_path(:monitor_id, :week_ending_date)
weekly_monitor_report_url(:monitor_id, :week_ending_date)

:as将把它放在url中;而不是。看起来我可以使用嵌套资源route.rb`resource:report do resources:monitor\u id do resources:week\u ending\u dates do resource:report end`
weekly_monitor_report_path(:monitor_id, :week_ending_date)
weekly_monitor_report_url(:monitor_id, :week_ending_date)