Skip to content

Commit

Permalink
Allow setting first-time-slug
Browse files Browse the repository at this point in the history
In our application we allow users to set the slug.
This works fine for content that already exists (is persisted to DB), but when creating new content the slug generator will override the given slug resulting in duplicates.
  • Loading branch information
Tuxified authored Jul 4, 2024
1 parent 1d19dd7 commit 526a992
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ecto_autoslug_field/slug_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ defmodule EctoAutoslugField.SlugGenerator do
slug_builder = Keyword.get(opts, :slug_builder)
always_change = Keyword.get(opts, :always_change, false)

slug_field = Map.get(changeset.data, slug_key)
slug_field = Ecto.Changeset.get_field(changeset, slug_key)

if always_change == true or slug_field == nil do
# We only generate slug on two occasions:
Expand Down

0 comments on commit 526a992

Please sign in to comment.