Is there a better way of having ajax return real-time data than creating a controller for this task and calling to it via $.ajax every so often?
For example, to fetch data from Redis, I've a controller with methods along the lines of
def get_size
begin
render :text => JSON.generate({:data => redis_instance.get("some_key"})
rescue Exception => e
render :text => JSON.generate({:data => nil})
end
end
Then I have $.ajax call to /get_size. Is this an acceptable practice or are there far better alternatives I don't know about?