How do i view the output of a route in iex
?
I know i can do this with mix Phoenix.routes
but would like to do this interactively.
Here is an example of what I would like to do:
iex -S Phoenix.server
mymodel_path
this gives me this error:
** (CompileError) iex:2: undefined function mymodel_path/0
All the url/path helpers are compiled into functions in the module YourApp.Router.Helpers
. You can import it and call with the same arguments as you would in your templates (you would probably pass conn
as the first argument but since we don't have a conn
in the iex
session, you can pass YourApp.Endpoint
instead):
iex(1)> import YourApp.Router.Helpers
nil
iex(2)> page_path(YourApp.Endpoint, :index)
"/"
iex(3)> task_path(YourApp.Endpoint, :show, 1)
"/tasks/1"
(I have a resources "/tasks", TaskController
in this project.)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments