Skip to content

Instantly share code, notes, and snippets.

@MartinElvar
Last active November 6, 2016 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinElvar/48cd8f776659d772976cedad5c90a337 to your computer and use it in GitHub Desktop.
Save MartinElvar/48cd8f776659d772976cedad5c90a337 to your computer and use it in GitHub Desktop.
defmacro belongs_to(model) do
[_ | module] = Module.split(unquote(model))
key = Macro.underscore(module) <> "_id" |> String.to_atom
quote do
.....
> belongs_to(Users.User)
== Compilation error on file lib/storages/schemas/storage_schema.ex ==
** (FunctionClauseError) no function clause matching in Module.split/1
(elixir) lib/module.ex:1006: Module.split({:__aliases__, [line: 13], [:Users, :User]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment