From 541187c3ea0c546848fc139b0d4deaa7a1f8738d Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sun, 5 Mar 2017 02:38:14 +0800 Subject: [PATCH] Update --- cssnext.md | 2 +- phoenix-ecto.md | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cssnext.md b/cssnext.md index ce2fda4c1..cb421901e 100644 --- a/cssnext.md +++ b/cssnext.md @@ -39,7 +39,7 @@ a { color: #0000ff80; /* rgba(0, 0, 255, 0.5) */ color: hwb(90, 0%, 0%, 0.5); /* like hsl() but easier for humans */ - color: hsl(90deg 90% 70%%); /* hsl(180, 90%, 70%) -- supports deg */ + color: hsl(90deg 90% 70%); /* hsl(180, 90%, 70%) -- supports deg */ color: hsl(90deg 90% 70% / 30%); /* hsla(180, 90%, 70%, 0.3) */ color: rgb(30 60 90 / 30%); /* rgba(30, 60, 90, 0.3) */ } diff --git a/phoenix-ecto.md b/phoenix-ecto.md index 030bf2394..5abaa07d6 100644 --- a/phoenix-ecto.md +++ b/phoenix-ecto.md @@ -32,6 +32,9 @@ end ```elixir def changeset(user, params \\ :empty) do + %User{} + |> Ecto.Changeset.change # basic casting to changeset + user |> cast(params, ~w(name email), ~w(age)) # params to Changeset @@ -54,8 +57,8 @@ def changeset(user, params \\ :empty) do |> unique_constraint(:email) |> foreign_key_constraint(:post_id) - |> assoc_constraint(:post) # ensure post_id exists - |> exclude_constraint(:name) + |> assoc_constraint(:post) # ensure post_id exists + |> no_assoc_constraint(:post) # negative (useful for deletions) end ``` @@ -64,7 +67,8 @@ changeset.valid? changeset.errors #=> [title: "empty"] changeset.changes #=> %{} -changeset.params +changeset.params[:title] + changeset.required #=> [:title] changeset.optional #=> [:body] ```