找不到用户名模板

你好,

我在用户名方面遇到一个奇怪的问题,我的版块使用 RTL 和阿拉伯语关键词的独特语言。

用户名设置为英文单词,但当我查看日志时,它显示用户配置文件模板找不到……因为它是用阿拉伯语关键词设置的……

当我查看用户名进行更改时,它设置为英文,但在错误中它显示阿拉伯语关键词……

这是完整的错误。

消息

ActionView::Template::Error (No route matches {:action=>"show", :controller=>"users", :username=>"دعم_المجتمع"}, possible unmatched constraints: [:username]
Did you mean?  user_url
               users_url
               users_path
               user_badge_url)
app/views/about/index.html.erb:17
app/views/about/index.html.erb:15
app/controllers/about_controller.rb:16:in `block (2 levels) in index'
app/controllers/about_controller.rb:14:in `index'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:354:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'

Backtrace

actionpack (6.1.4.1) lib/action_dispatch/journey/formatter.rb:44:in `path'
actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:823:in `url_for'
actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:270:in `call'
actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:326:in `block in define_url_helper'
app/views/about/index.html.erb:17
activerecord (6.1.4.1) lib/active_record/relation/delegation.rb:88:in `each'
activerecord (6.1.4.1) lib/active_record/relation/delegation.rb:88:in `each'
app/views/about/index.html.erb:15
actionview (6.1.4.1) lib/action_view/base.rb:247:in `public_send'
actionview (6.1.4.1) lib/action_view/base.rb:247:in `_run'

环境

HTTP HOSTS: forum.com

我相信我们必须从容器内部解决这个问题,因为我在管理面板中尝试了一切但都不起作用。

有什么建议吗?

在 Discourse 中应用唯一字符的建议是什么?这样我们就可以使用阿拉伯语或带有唯一 UTF-8 编码的用户名?

我恐怕没有阿拉伯语用户名的经验,但这是否是 unicode usernames 可以提供帮助的情况?

正确,已经检查过了但问题依旧存在;不过现在错误变了;

Message

NoMethodError (undefined method `url' for nil:NilClass)
app/models/badge.rb:306:in `image_url'
(eval):10:in `_fast_attributes'
lib/freedom_patches/ams_include_without_root.rb:54:in `include!'
lib/freedom_patches/ams_include_without_root.rb:54:in `include!'
app/controllers/application_controller.rb:510:in `render_json_dump'
app/controllers/users_controller.rb:97:in `block (2 levels) in show'
app/controllers/users_controller.rb:89:in `show'
app/controllers/users_controller.rb:103:in `show_card'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/middleware/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:356:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'

Backtrace

app/models/badge.rb:306:in `image_url'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:99:in `block in attribute'
(eval):10:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:448:in `block in merge_association'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:445:in `each'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:445:in `merge_association'

Env

HTTP HOSTS: site.com

我的论坛徽章部分似乎有问题;但我不知道如何在容器中运行此命令;

Discourse.system_user.create_user_profile

此命令将修复徽章问题;但如果有人能提供如何运行此命令?或在哪里运行?我会很感激。

[1] pry(main)> Discourse.system_user.create_user_profile
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "user_profiles_pkey"
DETAIL:  Key (user_id)=(-1) already exists.

from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:69:in `exec_params'
Caused by PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "user_profiles_pkey"
DETAIL:  Key (user_id)=(-1) already exists.

from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:69:in `exec_params'

谢谢。

你为什么这么认为?我不认为 create_user_profile 方法是供手动运行的,它是在用户创建后由 Discourse 运行的 discourse/app/models/user.rb at main · discourse/discourse · GitHub
这就是为什么你会得到 duplicate key value 错误,因为你试图创建已存在的用户配置文件。

我试图通过创建一个用户名为 دعم_المجتمع 的帐户来复制此错误,并且我还用英文用户名的帐户进行了测试,两者都将界面语言设置为阿拉伯语,并且运行正常。

我认为这个问题不再与语言或模板有关,而是与徽章缺少图像有关,正如你在这里指出的 Badge image missing issue

你说得对;无论如何,这是一个备份,我恢复了它,它运行正常……问题只出在徽章图片上;我尝试运行命令

rake uploads:clean_up
rake posts:rebake

但问题仍然存在……

[2] pry(main)> Discourse.system_user.create_user_profile
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "user_profiles_pkey"
DETAIL:  Key (user_id)=(-1) already exists.

from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:69:in `exec_params'
Caused by PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "user_profiles_pkey"
DETAIL:  Key (user_id)=(-1) already exists.

from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:69:in `exec_params'
[3] pry(main)> 
1 个赞