Created
February 28, 2017 01:48
-
-
Save thebugcatcher/fe0e623dff105790490b810a07e2721f to your computer and use it in GitHub Desktop.
Rummage Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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