Skip to content

Instantly share code, notes, and snippets.

@stochastic-thread
Created May 12, 2015 19:03
Show Gist options
  • Save stochastic-thread/8d09600e8d742beffc43 to your computer and use it in GitHub Desktop.
Save stochastic-thread/8d09600e8d742beffc43 to your computer and use it in GitHub Desktop.
defmodule Thinker.User do
use Thinker.Web, :model
schema "users" do
field :username, :string
timestamps
end
@required_fields ~w(username)
@optional_fields ~w()
@doc """
Creates a changeset based on the `model` and `params`.
If `params` are nil, an invalid changeset is returned
with no validation performed.
"""
def changeset(model, params \\ nil) do
model
|> cast(params, @required_fields, @optional_fields)
end
end
@stochastic-thread
Copy link
Author

Error message:

Compiled lib/thinker.ex

== Compilation error on file web/models/user.ex ==
** (CompileError) web/models/user.ex:4: undefined function schema/2
    (stdlib) lists.erl:1352: :lists.mapfoldl/3
    (stdlib) lists.erl:1353: :lists.mapfoldl/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment