Answer the question
In order to leave comments, you need to log in
How to refresh a specific page (Action Cable)?
A simple application: creating tasks, all tasks are displayed on the index page.
I want that when someone creates a task on the new page, everyone else's index page is updated.
events_controller.rb
def create
@event = Event.new(event_params)
if @event.save
ActionCable.server.broadcast 'room_channel',
name: @event.name,
description: @event.description
redirect_to root_url
else
render 'new'
end
end
received: (data) ->
$('#events').append '<h1>' + data.name + '</h1>' +
'<p>' + data.description + '</p>'
Answer the question
In order to leave comments, you need to log in
Well, somehow you need to cling jquery, it was cut out in the 5th rails
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question