似乎无法让 hotwire-rails `turbo_stream_from` 工作

如何解决似乎无法让 hotwire-rails `turbo_stream_from` 工作

我安装了 hotwire-rails gem 并运行了 rails hotwire:install,它似乎工作正常。

当我从视图调用方法 turbo_stream_from "posts" 时,收到以下错误,我完全不明白。

undefined method `then' for "posts":String

在多个示例中,我看到一个字符串被传递给方法 turbo_stream_from,以标识流名称。我尝试检查 repo,但根据我对所见所闻的了解,我没有找到太多东西。有谁知道我可能会缺少哪些部分才能使其正常工作?

turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:21:in `stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `block in stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `map'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:13:in `signed_stream_name'
turbo-rails (0.5.1) app/helpers/turbo/streams_helper.rb:20:in `turbo_stream_from'
app/views/forms/index.html.haml:6
actionview (6.0.3.5) lib/action_view/base.rb:274:in `_run'
actionview (6.0.3.5) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.3.5) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.3.5) lib/action_view/template.rb:385:in `instrument_render_template'
actionview (6.0.3.5) lib/action_view/template.rb:183:in `render'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:58:in `block (2 levels) in render_template'
actionview (6.0.3.5) lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.3.5) lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:57:in `block in render_template'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:65:in `render_with_layout'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:56:in `render_template'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionview (6.0.3.5) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.0.3.5) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.0.3.5) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (6.0.3.5) lib/action_view/base.rb:304:in `in_rendering_context'
actionview (6.0.3.5) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (6.0.3.5) lib/action_controller/Metal/streaming.rb:218:in `_render_template'
actionview (6.0.3.5) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.0.3.5) lib/action_controller/Metal/rendering.rb:52:in `render_to_body'
actionpack (6.0.3.5) lib/action_controller/Metal/renderers.rb:142:in `render_to_body'
actionpack (6.0.3.5) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.0.3.5) lib/action_controller/Metal/rendering.rb:36:in `render'
actionpack (6.0.3.5) lib/action_controller/Metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (6.0.3.5) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/Users/renevanpelt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
activesupport (6.0.3.5) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.0.3.5) lib/action_controller/Metal/instrumentation.rb:44:in `block in render'
actionpack (6.0.3.5) lib/action_controller/Metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (6.0.3.5) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.0.3.5) lib/action_controller/Metal/instrumentation.rb:43:in `render'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:30:in `render'
actionpack (6.0.3.5) lib/action_controller/Metal/implicit_render.rb:35:in `default_render'
actionpack (6.0.3.5) lib/action_controller/Metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.0.3.5) lib/action_controller/Metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.0.3.5) lib/action_controller/Metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.5) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.5) lib/action_controller/Metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:112:in `block in run_callbacks'
activesupport (6.0.3.5) lib/active_support/core_ext/time/zones.rb:66:in `use_zone'
app/controllers/dashboard_controller.rb:32:in `set_time_zone'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:121:in `block in run_callbacks'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:139:in `run_callbacks'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.5) lib/action_controller/Metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.5) lib/action_controller/Metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.5) lib/action_controller/Metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.5) lib/action_controller/Metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.5) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.5) lib/abstract_controller/base.rb:136:in `process'

更新:我生成一个新的 rails 6 应用程序,它运行良好。给出错误的应用刚刚从 rails 5 迁移到 rails 6。也许这就是两种情况之间的区别所在。

解决方法

今天刚遇到同样的问题。原来我使用的是 ruby​​ 2.5,但 then 是在 ruby​​ 2.6 中引入的。

将 ruby​​ 升级到 2.6.6 解决了这个问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?