hibiken / stories

Medium clone built with Ruby on Rails
https://my-medium-clone.herokuapp.com/
MIT License
806 stars 270 forks source link

Duplicate Slugs #23

Open danleecreates opened 8 years ago

danleecreates commented 8 years ago

When trying to publish a story with a slug that is the same as a story that is already published you get an error. Discovered by accident.

hibiken commented 8 years ago

Could you walk me through how to reproduce that error? because when I try creating multiple posts with the same title, the app generates a slug with the title and some random string concatenated at the end(which is what we want)

danleecreates commented 8 years ago

Hi Ken,

  1. I selected an old Untitled draft from my list of drafts
  2. I deliberately name it something with the same title that is already published
  3. I go to publish the story
  4. I get the following error:

PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_posts_on_slug" DETAIL: Key (slug)=(hello-world) already exists. : UPDATE "posts" SET "published_at" = $1, "slug" = $2, "lead" = $3, "updated_at" = $4 WHERE "posts"."id" = $5

hibiken commented 8 years ago

Are you working off of master branch?

danleecreates commented 8 years ago

Yes I was. If I write a new post it doesn't have the same issue - it is only older drafts that have no content.

AjayBarot commented 7 years ago

@kenny-hibino : Let me know If you can reproduce the error which mention by @nearkingdom .