我是 Elixir/Phoenix 的新手,我想知道是否有办法基本上 require IEx
用于 IEx.pry
以与在 Ruby/Rails 中相同的方式,您可以添加类似
group :test, :development do
gem 'pry', require: 'pry'
end
这将允许您
binding.pry
基本上在任何文件中,而无需包含 require 'pry'
我发现必须
require IEx
在任何 Controller 、模型、 View 等上,我想调试很乏味。
最佳答案
您可以使用 web/web.ex
文件。
A module that keeps using definitions for controllers, views and so on.
This can be used in your application as:
use App.Web, :controller use App.Web, :view
The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused on imports, uses and aliases.
就放
require IEx
当您需要它用于 Controller 、模型等时。defmodule App.Web do
def model do
quote do
...
require IEx
end
end
def controller do
quote do
...
require IEx
end
end
end
关于elixir - Phoenix : Requiring IEx in only :dev and :test for entire project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41513686/