Skip to content

Instantly share code, notes, and snippets.

class Comment < ActiveRecord::Base
belongs_to :message
belongs_to :user
after_commit { CommentRelayJob.perform_later(self) }
end
class CommentRelayJob < ApplicationJob
def perform(comment)
ActionCable.server.broadcast "messages:#{comment.message_id}:comments",
comment: CommentsController.render(partial: 'comments/comment', locals: { comment: comment })
end
end
App.comments = App.cable.subscriptions.create "CommentsChannel",
collection: -> $("[data-channel='comments']")
connected: ->
# FIXME: While we wait for cable subscriptions to always be finalized before sending messages
setTimeout =>
@followCurrentMessage()
@installPageChangeCallback()
, 1000
@tomomura
tomomura / gist:cc34bb07e7c7fa331213
Last active August 29, 2015 14:25
Install redis
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
make install
@tomomura
tomomura / gist:01df5ce5a7b5b7eb9edc
Created April 1, 2015 00:00
Rails on IIS Web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*"
modules="httpPlatformHandler"
resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpPlatform stdoutLogEnabled="true"
startupTimeLimit="20"
@tomomura
tomomura / gist:39a006413c6b390aefdd
Last active August 29, 2015 14:16
OpenStackの設定ファイル
# コントローラー
# /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
# (ListOpt) List of network type driver entrypoints to be loaded from
# the neutron.ml2.type_drivers namespace.
#
# type_drivers = local,flat,vlan,gre,vxlan
type_drivers = vxlan
# Example: type_drivers = flat,vlan,gre,vxlan
@tomomura
tomomura / gist:962e2f74548fd36772ab
Last active August 29, 2015 14:15
RuboComp example
def this_name
if any
'this is name'
end
'this is another name'
end