Error when I tried to add permalinks manually
AI-generated summary
In a discussion titled ‘Adding permalinks error,’ Christian_Suntay reports encountering an error when manually adding permalinks, even when no duplicate URLs exist. simon notes the error typically occurs when attempting to reuse an existing permalink URL, suggesting the form works as intended but lacks a clear error message. Christian_Suntay clarifies the error appears every time, regardless of URL uniqueness. pfaffman advises using the console for creating permalinks via Ruby code, such as Permalink.find_or_create_by(url: 'some/path/you/like', topic_id: 123), to avoid conflicts. They caution that including a leading / in the URL (e.g., /some/path/you/like) will cause subsequent calls to fail due to automatic stripping. For correcting or deleting incorrect permalinks, they recommend retrieving and destroying the record with p=Permalink.find_by(url: 'some/path/you/like'); p.destroy if p. The consensus leans toward console-based management for reliability and avoiding UI limitations.
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?
There is no same url created already and Any time i tried to add a permalink this error shows up ![]()
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
