Sha256: 1bd1e970625661a53e2823acff021774699f81486ecb299a14b25fdedcfb0b28
Contents?: true
Size: 692 Bytes
Versions: 1
Compression:
Stored size: 692 Bytes
Contents
require 'sinatra' if development? require 'bundler' require 'sinatra/reloader' Bundler.require end require 'sinatra/liveviews' require './lib/model' configure :development do also_reload './lib/model.rb' end get '/' do redirect to('/admin/stats') end get '/admin/stats' do erb :home end live '/admin/stats' do |document| document.on_load do document.element('#js-count').text = 'ready' end UserScore.where(:user_id => 1).on_count_change do |scores| document.element('#js-count').text = "#{scores.count} records" document.element('#js-sum').text = "total: #{scores.sum(:score).round}" document.element('#js-avg').text = "avg: #{scores.avg(:score).round(2)}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra-liveviews-0.5.0 | demo/app.rb |