我在Docker环境中使用Rails 5,我可以使用worker.new.perform让Action Cable在Sidekiq worker上完全正常播放.
但是对于我的生活,我在使用worker.perform_async时无法进行广播.
这是我的cable.yml:
default: &default
adapter: redis
url: <%= ENV['REDIS_PROVIDER'] %>
development:
<<: *default
test:
<<: *default
production:
<<: *default
Run Code Online (Sandbox Code Playgroud)
这是我的工人:
class AdminWorker
include Sidekiq::Worker
def perform
ActionCable.server.broadcast 'admin_channel', content: 'hello'
end
end
Run Code Online (Sandbox Code Playgroud)
我的管理频道:
class AdminChannel < ApplicationCable::Channel
def subscribed
stream_from "admin_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
Run Code Online (Sandbox Code Playgroud)
正如我之前提到的,调用AdminWorker.new.perform时,这很好用.一旦我尝试运行AdminWorker.perform_async,电缆就不会广播,对日志中的动作电缆没有任何帮助.我在这里错过了什么?
因此,我使用 keycloak 作为身份验证机制,并通过修改 login.ftl 文件来自定义登录页面。到目前为止,一切都很好。我正在我的 login.ftl 中导入 template.ftl 文件 - 按照 keycloak 文档的指示 - 到目前为止一切顺利。在该 template.ftl 文件中 - 有一种方法可以访问错误消息,如下所示
<#if displayMessage && message?has_content && (message.type != 'warning' || !isAppInitiatedAction??)>
<div class="alert alert-${message.type}">
<#if message.type = 'success'><span class="${properties.kcFeedbackSuccessIcon!}"></span></#if>
<#if message.type = 'warning'><span class="${properties.kcFeedbackWarningIcon!}"></span></#if>
<#if message.type = 'error'><span class="${properties.kcFeedbackErrorIcon!}"></span></#if>
<#if message.type = 'info'><span class="${properties.kcFeedbackInfoIcon!}"></span></#if>
<span class="kc-feedback-text">${kcSanitize(message.summary)?no_esc}</span>
</div>
</#if>
Run Code Online (Sandbox Code Playgroud)
太好了!如果我不想处理 template.ftl 文件中的错误消息 ui 怎么办?我在login.ftl 页面上有一个表单UI,我想在其中显示错误消息。如何将该消息传递到login.ftl 文件或从login.ftl 文件访问该错误消息?预先感谢您的任何指导。
freemarker keycloak custom-theme keycloak-services error-messaging
所以我只想从常规地址(字符串)中提取经度/纬度坐标.我去了geokit gem文档并准确地做了记录,但我不断收到这个错误:"NameError:uninitialized constant Geokit :: Geocoders :: OpenSSL"
我在gemfile中加了"geokit",这个:
require 'rubygems'
require 'geokit'
def get_coordinates
@a = Geokit::Geocoders::GoogleGeocoder.geocode '140 Market St, San Francisco, CA'
@a.ll
end
Run Code Online (Sandbox Code Playgroud)
我之前也试过添加它,但无济于事.Geokit :: Geocoders :: GoogleGeocoder.api_key = api_key
我只想要坐标,如果这不是一个可行的解决方案,有人可以推荐另一个地理编码器.我尝试过railscast,但也无法使用它.非常感谢任何帮助!