Reputation: 193
I'm new to Elixir/Phoenix and I was wondering if there was a way to essentially require IEx
for the purpose of IEx.pry
in the same manner that in Ruby/Rails you can add something like
group :test, :development do
gem 'pry', require: 'pry'
end
which would allow you to binding.pry
in essentially any file without needing to include require 'pry'
I'm finding that having to require IEx
on any controller, model, view, etc I want to debug to be tedious.
Upvotes: 7
Views: 597
Reputation: 628
You can use web/web.ex
file.
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.
Just put require IEx
here when you need it for controllers, models etc.
defmodule App.Web do
def model do
quote do
...
require IEx
end
end
def controller do
quote do
...
require IEx
end
end
end
Upvotes: 1