Adding permalinks error

Error when I tried to add permalinks manually

I can reproduce that error if I add a value to the URL field that I’ve already created a permalink for. In that case, I think the form is working as expected, but the error message is not very informative.

Are you getting this error any time you try to add a permalink, or is it only happening with specific permalinks?

1 Like

There is no same url created already and Any time i tried to add a permalink this error shows up :frowning:

1 Like

You almost certainly want to be creating permalinks from the console, not the web interface, with something like

Permalink.find_or_create_by(url: 'some/path/you/like', topic_id: 123)

That way it won’t matter if you call it multiple times.

Note that if you instead do:

Permalink.find_or_create_by(url: '/some/path/you/like', topic_id: 123)

it will fail on subsequent calls because it’ll strip the leading / before it does the create.

And if you really do want to delete/change paths that you created wrong the first time, you’d do something like

p=Permalink.find_by(url: 'some/path/you/like')
p.destroy if p
3 Likes