Created
July 19, 2017 14:18
-
-
Save sobolevn/49fcdb7b1768e09b18195793d31d56b0 to your computer and use it in GitHub Desktop.
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 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