Rails:从控制台检查路径助手的输出 - Rails: Check output of path helper from console

问题:

Rails defines a bunch of magic with named routes that make helpers for your routes. Rails 定义了一堆带有命名路由的魔法,它们为你的路由提供帮助。 Sometimes, especially with nested routes, it can get a little confusing to keep track of what URL you'll get for a given route helper method call.有时,尤其是对于嵌套路由,跟踪给定路由辅助方法调用将获得的 URL 可能会有些混乱。 Is it possible to, using the Ruby console, see what link a given helper function will generate?是否可以使用 Ruby 控制台查看给定的辅助函数将生成什么链接? For example, given a named helper like post_path(post) I want to see what URL is generated.例如,给定一个像 post_path(post) 这样的命名助手,我想看看生成了什么 URL。


解决方案:

参考一: https://en.stackoom.com/question/BwRD
参考二: https://stackoom.com/question/BwRD
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章