Coder Social home page Coder Social logo

Comments (4)

apai4 avatar apai4 commented on April 29, 2024 1

@xemexpress The original thinking was that you wouldn't want your URL's to change when the author makes changes to the title otherwise you could get broken links if someone linked to an article externally.

You can make the slugs update on every save by changing this line in article.rb in the before_validation block:

before_validation do
- self.slug ||= "#{title.to_s.parameterize}-#{rand(36**6).to_s(36)}"
+ self.slug = "#{title.to_s.parameterize}-#{rand(36**6).to_s(36)}"
end

from realworld.

EricSimons avatar EricSimons commented on April 29, 2024

This is intended functionality, no?

from realworld.

xemexpress avatar xemexpress commented on April 29, 2024

Yes though 😛 I just don't know why users shouldn't make that change (on :slug)
Any help?

from realworld.

EricSimons avatar EricSimons commented on April 29, 2024

Ahhh I understand what you're saying now. Changing the slug won't actually cause anything to break, as the frontends redirect to whatever slug you hand back in the article payload for the PUT request. So updating slugs are a "nice-to-have" but not mission critical for core functionality :)

That said, @apai4 any recs on how the Rails stack could support updating article slugs?

Btw I just updated the API spec w/ the delete call FYI, shocked no one has caught that until now!

from realworld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.