I know rails a little and I have some Idea.
this code in topic controller is not working well. As I tested some puts in console. I have find out that this part of topic controller has some problem. And I found out that there is no extra whitespace after this.
params[:slug]
I have tested some codes to find out if there is extra whitespace after slug or not. so I added the following to topic_controller:
puts "'#{params[:slug]}'"
puts params[:slug].length
puts "'#{@topic_view.topic.slug}'"
puts @topic_view.topic.slug.length
and the out put was this:
'مشکل-پیدا-کردن-ترجمه-ی-خوب'
47
'مشکل-پیدا-کردن-ترجمه-ی-خوب'
26
I added a single quotation around the out put to see whatespace in console there is no whitespace between the slug and the single quotation. the are exactly the same but the length is diffrent.
UPDATE:
look at the code I have changed and the output:
code:
puts "'#{params[:slug]}'"
puts params[:slug].length
puts params[:slug].encoding
puts "'#{@topic_view.topic.slug}'"
puts @topic_view.topic.slug.length
puts @topic_view.topic.slug.encoding
output:
'مشکل-پیدا-کردن-ترجمه-ی-خوب'
47
ASCII-8BIT
'مشکل-پیدا-کردن-ترجمه-ی-خوب'
26
UTF-8