問題:
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