LoginSignup
15
10

More than 5 years have passed since last update.

Rails console で url helper のデバッグ方法メモ

Posted at

結論から言うと app をレシーバにすると helper や view で使えるメソッドが呼び出せます

controller / action 名から URL を出す

pry(main)> app.url_for(action: :show, controller: 'users', id: 1)
=> "http://www.example.com/users/1"

path helper メソッドから path を出す

pry(main)> app.users_path(id: 1)
=> "/users/1"
15
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
10