我有这个样本:
我设法创建了这个表单,但遗憾的是它不起作用,因为我收到了错误.
Dropzone already attached.
Run Code Online (Sandbox Code Playgroud)
代码HTML:
<div class="dropzone dz-clickable" id="myDrop">
<div class="dz-default dz-message" data-dz-message="">
<span>Drop files here to upload</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
代码JS:
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("div#myDrop", { url: "/file/post"});
// If you use jQuery, you can use the jQuery plugin Dropzone ships with:
$("div#myDrop").dropzone({ url: "/file/post" });
Run Code Online (Sandbox Code Playgroud)
我设置 Dropzone.autoDiscover = false;但不幸的是仍然没有工作.
你能告诉我是什么原因引起了这个问题吗?
我正在尝试使用Rails 4的直播流实现文本/事件流.它工作得很好,我遇到的唯一麻烦就是我无法在不发送任何消息的情况下检查连接是否存在.
我想出的唯一解决方案是使用循环刻度生成器创建支持通道,以便某些后台任务将定期发送消息.但它似乎是凌乱和不可靠的.更好的解决方案?
这是我的控制器:
require 'persistency/sse'
require 'persistency/track'
class PersistencyController < ApplicationController
include ActionController::Live
def stream
response.headers['Content-Type'] = 'text/event-stream'
sse = Persistency::SSE.new(response.stream)
track = Persistency::Track.new(current_user)
redis = Redis.new
begin
redis.subscribe(:info, :chat) do |on|
on.message do |channel, message|
sse.write({ :message => message }, :event => channel)
end
end
rescue IOError
ensure
track.close
sse.close
end
end
end
Run Code Online (Sandbox Code Playgroud) 我有一个旧的 Rails 5.1 应用程序。我们最近开始使用 docker-compose。我们使用 puma 和 nginx 来启动应用程序,例如:
bundle exec puma -d && nginx -g "daemon off;"
Run Code Online (Sandbox Code Playgroud)
将此映射用于盆:
version: '3'
services:
...
web:
ports:
- 3001:80
Run Code Online (Sandbox Code Playgroud)
工作正常(但我看不到 rails 应用程序的任何日志)。我需要能够使用 byebug gem 来调试我的 Rails 应用程序。
我试过这个,但没有任何运气:
web: ...
stdin_open: true
tty: true
Run Code Online (Sandbox Code Playgroud)
$ docker-compose up -d
$ docker attach app_web_1
Run Code Online (Sandbox Code Playgroud)