Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sobolevn/49fcdb7b1768e09b18195793d31d56b0 to your computer and use it in GitHub Desktop.
Save sobolevn/49fcdb7b1768e09b18195793d31d56b0 to your computer and use it in GitHub Desktop.
defmodule EctoSlugs.Blog.Article.TitleSlug do
use EctoAutoslugField.Slug, to: :slug
import Ecto.Changeset
def get_sources(changeset, _opts) do
# This function is used to get sources to build slug from:
base_fields = [:title]
if get_change(changeset, :breaking, false) do
["breaking"] ++ base_fields
else
base_fields
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment