Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question URLs are showing database IDs #330

Open
konklone opened this issue Feb 8, 2014 · 5 comments
Open

Question URLs are showing database IDs #330

konklone opened this issue Feb 8, 2014 · 5 comments
Assignees

Comments

@konklone
Copy link
Contributor

konklone commented Feb 8, 2014

This URL is, I think, showing a MongoDB database ID:

http://www.askthem.io/dc/questions/52f4fc01f92ea1bb98000009

Whatever it is, I'd turn that into a slug before your formal launch, for a few reasons:

  • Better clickthrough rates, people will have an idea of what they'll be taken to
  • Better SEO
  • More future-proof URL architecture - you can change the underlying system more easily
@davidmooreppf
Copy link
Member

Thx Eric, good suggestions - appreciate it - we're just getting around to some of this, happy to have Walter take a look. Our DB of elected officials is still pretty flux-y. But very on-point.

@walter
Copy link
Contributor

walter commented Feb 8, 2014

There are at least three classes where we may want to do this right now:

  • questions
  • people (already done for state legislators and federal legislators)
  • users

All three are tricky because the natural "stub url" would be non-unique names or titles.

Normally you would deal with this by adding a "scope" (i.e. all question titles must be unique for a jurisdiction), but these three classes using a scope (or scopes, e.g. unique title for person for specific jurisdiction by a particular user) won't work elegantly. We would probably end up with ugly urls anyway.

I'll consider it more. I would say that the priority is having a stub url for questions and people. Users are a nice to have. The solution that comes to mind is having a sequence attribute and add that to the title. Possibly timestamp as alternative to sequence.

@konklone if you have an alternative approach, I'm all ears.

@konklone
Copy link
Contributor Author

konklone commented Feb 8, 2014

If it's helpful, I'm using mongoid-slug to power the URLs for posts on my blog. It uses the database to reflect on whether a slug already exists and appends -1 or -2 as appropriate. It associates an array of slugs with each object, so you can alter slugs and still have old URLs resolve.

In other words, I would ignore the uniqueness constraint as an application-level concern, and allow dupe question/people/user names to generate nearly identical slugs, that mongoid-slug takes care of differentiating.

@walter
Copy link
Contributor

walter commented Feb 8, 2014

Cool. I had found mongo-slug (and was aware of it), but hadn't caught it handles our situation of non-unique titles and the like. Instead I focused on how you can specify scope, etc.

It's actually pretty much what I was suggesting for a sequence attribute. A tad simpler and I'm happy to have it implemented for me!

I'll do some experiments and see where it gets us. Thanks for you suggestions.

@walter
Copy link
Contributor

walter commented Feb 10, 2014

Did a little experiment on Question model to see if this is viable right away.

Unfortunately it looks like it will take some doing. At least it won't simply "just work" for us without further digging.

Too bad!

I do think we want to get this relatively soon, but just not in the next couple days probably.

A goal is that old URLs still work after the new slug URLs happen. This seems possible with mongoid-slug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants