意外と簡単だったがggってもなかなかヒットしなかったのでメモ。
やりたいこと
- rake タスクからurl_forを使ってとあるURLを作成したい
- routs.rbでごにょごにょしてる部分があるので、url_forで解決したい
- root_pathも呼びたい
解決方法
routes = Rails.application.routes.url_helpers
url = routes.url_for(host: "example.com", controller: "users", action: "show", id: 1)
rootpath = routes.root_path
以下じゃできなかった
* http://lxyuma.hatenablog.com/entry/2013/02/17/002744
* http://steve.dynedge.co.uk/2010/04/29/rails-3-rake-and-url_for/