gpt4 book ai didi

elixir - Phoenix : Requiring IEx in only :dev and :test for entire project

转载 作者:行者123 更新时间:2023-12-04 12:52:09 27 4
gpt4 key购买 nike

我是 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com