9
9
9karamba2019-04-23 14:56:12
Ruby on Rails
9karamba, 2019-04-23 14:56:12

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

room.coffee
received: (data) ->
      $('#events').append '<h1>' + data.name + '</h1>' +
        '<p>' + data.description + '</p>'

That's not updated, why I do not understand. What's wrong?
When I just write alert "check", it outputs to index, but it doesn't work like that

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vayladion Gognazdiak, 2019-04-23
@etspring

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 question

Ask a Question

731 491 924 answers to any question