Alavi1412
(SMHassanAlavi)
August 1, 2017, 1:51pm
1
Continuing the discussion from ERR_TOO_MANY_REDIRECTS After Rebuild :
I found out that the error ERR_TOO_MANY_REDIRECTS
after last update was because of non-english character in title. When I changed the slug generation method
to none, and created a new topic(that doesn’t include non-english character in slug and url) it opens with no error but that previous topics has still the problem.
PAY ATTENTION to URL:
pages with error:
pages without error:
So I think the problem is from the topic controller.
1 Like
Falco
(Falco)
August 1, 2017, 1:54pm
2
On your first screenshot the slug is after the topic_id, is that normal?
1 Like
Alavi1412
(SMHassanAlavi)
August 1, 2017, 1:55pm
3
Yes, This is because Persian is RTL language.
in fact the url is like this:
http://localhost:3000/t/%D8%A2%DB%8C%D8%A7-%D8%B2%D8%A8%D8%A7%D9%86-%D9%81%D8%A7%D8%B1%D8%B3%DB%8C-%D9%86%D9%82%D8%B4%DB%8C-%D8%AF%D8%B1-%D8%B4%DA%A9%D9%84%E2%80%8C%DA%AF%DB%8C%D8%B1%DB%8C-%D8%AA%D9%81%DA%A9%D8%B1-%D8%A7%D8%AD%D8%B3%D8%A7%D8%B3%DB%8C-%D9%88-%DB%8C%D8%A7-%D8%B9%D9%82%D9%84%D8%A7%D9%86%DB%8C-%D9%85%D8%A7-%D8%AF%D8%A7%D8%B1%D8%AF%D8%9F/4790
UPDATE:
I have done this to check the error in line 661 in definition of slug_do_not_match
method:
first check:
puts params[:slug]
puts @topic_view.topic.slug
puts @topic_view.topic.slug != params[:slug]
for English slug the output was like this:
topic
topic
false
for Persian slug the output was like this:
مشکل-پیدا-کردن-ترجمه-ی-خوب
مشکل-پیدا-کردن-ترجمه-ی-خوب
true
and I have changed the checking code like this:
puts params[:slug].length
puts @topic_view.topic.slug.length
puts @topic_view.topic.slug != params[:slug]
and the out put was interesting:
English slug:
6
6
false
BUT Persian slug:
36
66
true
I found out that it may save some whitespace after the name of the Persian slug(because whitespaces aren’t visible in console)
Pad_Pors
(Pad Pors)
August 1, 2017, 4:18pm
4
seems related (same error in the admin panel):
Ooooooh, this is going to get messy.
In theory, URLs can only contain 7-bit ASCII characters. In practice, everyone’s pretty much decided that percent-encoded UTF-8 is , which is why, if you look in the “env” for the log message, you’ll see something like
REQUEST_URI /tags/%D0%B7%D0%B5%D0%BC%D0%BB%D1%8F/notifications
(Which is the UTF-8 encoding for “земля”)
So, the problem is occuring because the contents of params is being encoded as ASCII-8BIT, and while most everything manages …
Did you try puts @topic_view.topic.slug != params[:slug].strip
And what’s the @topic_view.topic.slug.encoding
and params[:slug].encoding
?
mpalmer
(Matt Palmer)
August 1, 2017, 10:57pm
6
$20 says params[:slug].encoding
is ASCII-8BIT
. I think we need to fix this everywhere, as per this topic .
3 Likes
Alavi1412
(SMHassanAlavi)
August 3, 2017, 6:29am
7
yes and the problem still exist. .strip
method won’t solve it.
Pad_Pors
(Pad Pors)
August 6, 2017, 2:49pm
8
we had faced this problem in our site, and to solve it temporarily and for short time:
1- we changed the slug generation method
in admin panel to none.
2- then we created a temp category, and select all old topics with Persian slug, move them to that category, and bring them back!
this way the slug of all the topics became some simple topic-numbers without any Persian character. there’s a simpler way of using code lines in the link below, that I didn’t try:
Does editing the title on old topics fix the problem?
If so, something like this might work on the rails console:
Topic.all.each do |topic|
topic.title = topic.title
topic.save!
end
(Assigning topic.title re-generates the slug)
Please please please take a backup before trying that, as I don’t know if it will have any unintended side effects.
It might also take a long time to run depending how many topics you have…
2 Likes
tgxworld
(Alan Tan)
September 29, 2017, 4:26am
9
@Alavi1412 Can you upgrade to latest? This is fixed after we upgraded to Rails 5.1
4 Likes