In Phx 1.3 this code works, but in Phx 1.4 doesn’t want.
def index(conn, _params) do
current_user = Guardian.Plug.current_resource(conn)
owned_board = current_user
|> assoc(:owned_board)
|> board_preload_all
|> Repo.all
invited_board = current_user
|> assoc(:board)
|> not_owned_by(current_user.id)
|> board_preload_all
|> Repo.all
render(conn, "index.json", owned_board: owned_board, invited_board: invited_board)
end
Errors are obtained.
[error] #PID<0.501.0> running ImconWeb.Endpoint (connection #PID<0.500.0>, stream id 1) terminated
Server: caix.ru:4001 (http)
Request: POST /api/v1/sessions
** (exit) an exception was raised:
** (ArgumentError) argument error
:erlang.apply(%Imcon.Auth.User{__meta__: #Ecto.Schema.Metadata<:loaded, "user">, board: #Ecto.Association.NotLoaded<association :board is not loaded>, email: "john@phoenix-trello.com", encrypted_password: "$2b$12$nn1jeBQwQms.Id2JOeb6..mi8UQQka8dyWNkh0WqmAm/hN0AQX9zW", first_name: "John", id: 1, inserted_at: ~N[2019-01-02 08:36:35.417355], is_admin: false, last_name: "Doe", owned_board: #Ecto.Association.NotLoaded<association :owned_board is not loaded>, password: nil, updated_at: ~N[2019-01-02 08:36:35.426004], user_board: #Ecto.Association.NotLoaded<association :user_board is not loaded>}, :config, [])
(guardian) lib/guardian.ex:776: Guardian.token_module/1
(guardian) lib/guardian.ex:576: Guardian.encode_and_sign/4
(imcon) lib/imcon_web/controllers/api/v1/session_controller.ex:9: ImconWeb.SessionController.create/2
The configuration is such here.
[
{:phoenix, "~> 1.4.0"},
{:phoenix_pubsub, "~> 1.1.1"},
{:phoenix_ecto, ">= 3.2.0 and < 3.5.0"},
{:postgrex, ">= 0.0.0"},
{:poison, ">= 0.0.0"},
{:phoenix_html, "~> 2.12.0"},
{:phoenix_live_reload, "~> 1.2.0", only: :dev},
{:gettext, "~> 0.16.1"},
{:cowboy, "~> 2.6.0"},
{:plug_cowboy, "~> 2.0.0"},
{:comeonin, "~> 4.1.1"},
{:bcrypt_elixir, "~> 1.0.9"},
{:guardian, "~> 1.1.1"},
{:credo, "~> 0.10.2", only: [:dev, :test]},
{:ex_machina, "~> 2.2.2"},
{:exactor, "~> 2.2.4"},
{:hound, "~> 1.0.2"},
{:mix_test_watch, "~> 0.9.0", only: :dev},
{:poolboy, "~> 1.5.1"}
]