Skip to content

Instantly share code, notes, and snippets.

@kenmazaika
Created September 30, 2015 00:50
Show Gist options
  • Save kenmazaika/8465a10f4fcab06b1a89 to your computer and use it in GitHub Desktop.
Save kenmazaika/8465a10f4fcab06b1a89 to your computer and use it in GitHub Desktop.
defmodule Jarvis.Result do
use Jarvis.Web, :model
schema "results" do
field :title, :string
field :body, :string
timestamps
has_many :rules, Jarvis.Rule
end
@required_fields ~w(title body)
@optional_fields ~w()
@doc """
Creates a changeset based on the `model` and `params`.
If no params are provided, an invalid changeset is returned
with no validation performed.
"""
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fields, @optional_fields)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment