Slide 18
Slide 18 text
"DUJPO$BCMFͷDIBOOFMʹ͓͚Δ
DPOUSPMMFSͷׂΛ୲͍·͢ɻ
ͦͷͨΊɺ$36%ͷॲཧΛهड़ͯ͠·
͢ɻ
σʔλΛϒϩʔυΩϟετ͢Δ͜ͱͰɺ
νϟωϧʹσʔλΛૹΓ·͢ɻ
·ͨɺαϒεΫϥΠϒͨ࣌͠ɺαϒε
ΫϥΠϒ͕ऴΘͬͨ࣌ͷॲཧΛॻ͖·
͢ɻ
͜͜ͰɺαϒεΫϥΠϒͨ࣌͠ʹɺա
ڈͷใҰཡΛૹΔΑ͏ʹ͍ͯ͠·͢ɻ
UJNFMJOFT@DIBOOFMSCΛݟ͍ͯ͘
۩ମతͳίʔυ͕ཉ͍͠
class TimelinesChannel < ApplicationCable::Channel
include Rails.application.routes.url_helpers
def subscribed
stream_from "timelines_channel"
timelines = Timeline.order(created_at: :asc)
transmit({ event: "timelines", current_user: format_current_user, timelines: format_timelines(timelines) })
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
def create_timeline(data)
@timeline = Timeline.create!(user_id: current_user.id, description: data["description"])
ActionCable.server.broadcast "timelines_channel", { event: "create_timeline", timeline: format_timeline(@timeline) }
end
def update_timeline(data)
@timeline = Timeline.find_by(id: data["id"])
@timeline.update(description: data["description"])
ActionCable.server.broadcast "timelines_channel", { event: "update_timeline", timeline: format_timeline(@timeline) }
end
def delete_timeline(data)
@timeline = Timeline.find_by(id: data["id"])
@timeline.destroy
ActionCable.server.broadcast "timelines_channel", { event: "delete_timeline", timeline: format_timeline(@timeline) }
end
end