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

标签 elixir phoenix-framework elixir-iex

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

相关文章:

elixir - 从字符串中删除数值

elixir - 如何使用 Ecto 构建 WHERE IN 数组子句?

sass - 使用 Brunch 将 TailwindCSS 添加到 Phoenix

python - 在一个 session 下使用 python 运行 powershell 脚本

shell - Elixir - 从 shell 调用模块函数

testing - 使用 Elixir/ExUnit 实现数据驱动测试的首选方法是什么?

elixir - 是否可以在 Enum.each 中有 ExUnit.test 语句

javascript - 我如何简化这段代码?有更好的方法吗?

elixir - Phoenix : How to supervise an Agent?

Elixir/Phoenix 限制参数,如 Rails 强参数