@chrismccord: After uninstall old phoenix and install new archive (also when build archive from source) I have still two phoenix.* tasks:
> mix archive
* hex-0.16.1
* phoenix-1.3.0
Archives installed at: /home/eiji/.asdf/installs/elixir/1.5.0-otp-20/.mix/archives
> mix help
mix # Runs the default task (current: "mix run")
mix app.start # Starts all registered apps
mix app.tree # Prints the application tree
mix archive # Lists installed archives
mix archive.build # Archives this project into a .ez file
mix archive.install # Installs an archive locally
mix archive.uninstall # Uninstalls archives
mix clean # Deletes generated application files
mix cmd # Executes the given command
mix compile # Compiles source files
mix deps # Lists dependencies and their status
mix deps.clean # Deletes the given dependencies' files
mix deps.compile # Compiles dependencies
mix deps.get # Gets all out of date dependencies
mix deps.tree # Prints the dependency tree
mix deps.unlock # Unlocks the given dependencies
mix deps.update # Updates the given dependencies
mix do # Executes the tasks separated by comma
mix escript # Lists installed escripts
mix escript.build # Builds an escript for the project
mix escript.install # Installs an escript locally
mix escript.uninstall # Uninstalls escripts
mix help # Prints help information for tasks
mix hex # Prints Hex help information
mix hex.audit # Shows retired Hex dependencies
mix hex.build # Builds a new package version locally
mix hex.config # Reads, updates or deletes Hex config
mix hex.docs # Fetches or opens documentation of a package
mix hex.info # Prints Hex information
mix hex.outdated # Shows outdated Hex deps for the current project
mix hex.owner # Manages Hex package ownership
mix hex.publish # Publishes a new package version
mix hex.repo # Manages Hex repositories
mix hex.retire # Retires a package version
mix hex.search # Searches for package names
mix hex.user # Manages your Hex user account
mix loadconfig # Loads and persists the given configuration
mix local # Lists local tasks
mix local.hex # Installs Hex locally
mix local.public_keys # Manages public keys
mix local.rebar # Installs Rebar locally
mix new # Creates a new Elixir project
mix phoenix.gen.html # Generates controller, model and views for an HTML based resource
mix phoenix.server # Starts applications and their servers
mix phx.digest # Digests and compresses static files
mix phx.digest.clean # Removes old versions of static assets.
mix phx.gen.channel # Generates a Phoenix channel
mix phx.gen.context # Generates a context with functions around an Ecto schema
mix phx.gen.embedded # Generates an embedded Ecto schema file
mix phx.gen.html # Generates controller, views, and context for an HTML resource
mix phx.gen.json # Generates controller, views, and context for a JSON resource
mix phx.gen.presence # Generates a Presence tracker
mix phx.gen.schema # Generates an Ecto schema and migration file
mix phx.gen.secret # Generates a secret
mix phx.routes # Prints all routes
mix phx.server # Starts applications and their servers
mix profile.cprof # Profiles the given file or expression with cprof
mix profile.fprof # Profiles the given file or expression with fprof
mix run # Runs the given file or expression
mix test # Runs a project's tests
mix xref # Performs cross reference checks
iex -S mix # Starts IEx and runs the default task
As @chrismccord and @NobbZ wrote, there is no such module as Credentials in your code, so you have to use alias for proper module, namely Ins.Accounts.Credentials as we can see in the screenshot.
defmodule Ins.Accounts.Credential do
use Ecto.Schema
import Ecto.Changeset
alias Ins.Accounts.{Credential, User}
schema "credentials" do
field :email, :string
belongs_to :user, User
timestamps()
end
@doc false
def changeset(%Credential{} = credential, attrs) do
credential
|> cast(attrs, [:email])
|> validate_required([:email])
|> unique_constraint(:email)
end
end
User.ex
defmodule Ins.Accounts.User do
use Ecto.Schema
import Ecto.Changeset
alias Ins.Accounts.{User, Credential}
schema "users" do
field :name, :string
field :username, :string
has_one :credential, Credential
timestamps()
end
@doc false
def changeset(%User{} = user, attrs) do
user
|> cast(attrs, [:name, :username])
|> validate_required([:name, :username])
|> unique_constraint(:username)
end
end
Account.ex
defmodule Ins.Accounts do
@moduledoc """
The Accounts context.
"""
import Ecto.Query, warn: false
alias Ins.Repo
alias Ins.Accounts.User
@doc """
Returns the list of users.
## Examples
iex> list_users()
[%User{}, ...]
"""
def list_users do
User
|> Repo.all()
|> Repo.preload(:credential)
end
...
end
So in your InsWeb.Controllers.UserController (I’m guessing it is) at the top of your module definition you need to add something like alias Ins.Accounts.Credentials to bring Credentials into active scope.
Seeing this file is definitely what I needed. I’m guessing, based on counting, that this line is line 45:
case Accounts.update_user(user, user_params) do
And if so it is failing inside that, so next we need to see your INS.Account module, I bet it is that module that needs the alias (wherever the Credentials.changeset call actually exists is the same module where the alias needs to exist).
So yeah, the alias line you have commented out really should be all that is required. Actually I’m not sure how that module is even compiling without it since you struct-create the Credential in that file too. o.O?