Skip to content

Instantly share code, notes, and snippets.

@thebugcatcher
Created February 28, 2017 01:48
Show Gist options
  • Save thebugcatcher/fe0e623dff105790490b810a07e2721f to your computer and use it in GitHub Desktop.
Save thebugcatcher/fe0e623dff105790490b810a07e2721f to your computer and use it in GitHub Desktop.
Rummage Example
defmodule RummageExample.Product do
use RummageExample.Web, :model
use Rummage.Ecto, repo: RummageExample.Repo, per_page: 2 # <-- Add this
schema "products" do
field :name, :string
field :category, :string
field :quantity, :integer
timestamps()
end
@doc """
Builds a changeset based on the `struct` and `params`.
"""
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:name, :category, :quantity])
|> validate_required([:name, :category, :quantity])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment