Skip to content

Zedmor/page_views

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Little pluging, that make one sql-update per 100 (by default, you can make 1000 or 10) for each page request. Its use cookies to store information about user's views and Rails.cache for buffer.

Usage

Install

./script/plugin install git://github.com/preprocessor/page_views.git

Create migration

./script/generate page_views Post

Model:

class Post < ActiveRecord::Base
  with_page_views
end

Controller:

include PageViews::Controller

bafore_filter :increment_page_views, :only => [:show]

def increment_page_views
  page_views_increment @post #load @post before
end

View:

   @post.page_views

Options

with_page_views :buffer_size => 1000, :days => 3, :model_name => 'post'

buffer_size — how often to write down the value buffer in the database

days — how many days to store information about pages user visit in the cookie (by default 2 days)

with_page_views :with_buffer => false

with_buffer — not advised to switch off, even if you do not have memcache rails used by default MemoryStore.

model_name — custom name of model for keys in cookies and cache

ToDo

tests :)

About

SQL-less page views counters

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published