E
E
Evgeny Strashko2015-04-06 15:41:31
JavaScript
Evgeny Strashko, 2015-04-06 15:41:31

How to update data with an Ajax request in Rails?

Hello. Tell me how to update the information in the block using an Ajax request. Update once every ten seconds.
What file should I write javascript to?
my_controller.rb

def index
 @all_users = User.where(#здесь парамаетры поиска)
 @active_users = User.where(#здесь параметры поиска)
 end


index.html.erb
<h1>Статистика</h1>
<h2>Всего пользователей: <%= @all_users.count%> </h2>
<h2>Активных пользователей: <%= @active_users.count%> </h2>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Dyachuk, 2015-04-06
@Renius

Obviously in my.js

P
Pavel Bakhvalov, 2015-04-08
@theDeoxen

I think it will be clear here, just change it so that it was by the timer, and not by the search.
railscasts.com/episodes/240-search-sort-paginate-w...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question