Here's much more of an academic question for everyone. Say I wish to produce a model inside a ruby on rails application to trace simple sights information. I must record the consumer_id, the URI for that page seen, and keep an eye on the amount of occasions the consumer has visited a webpage.

Model A: One method to do this is to produce a model View with characteristics user_id and page (records the uri), after which produce a new entry whenever a user opens a webpage.

Model B: Another method of doing this is to include a characteristic "page_sights" towards the model, to trace the amount of occasions the consumer has utilized that page.

Benefits and drawbacks: Model A might have more details recorded and result in a bigger db than Model B. However, Model B would require that the controller look for a current user-page combination, and only add sights to that particular entry, or create a replacement. This can lead to a more compact database, but might be worse in scale because of the necessity to look for existing records.

So my question to everyone is: that is more essential? Are my ideas wrong? Shall We Be Held missing something here (other performance factors overlooked?)

NoSQL method of monitoring user activity:

model app/models/user.rb
class User < ActiveRecord::Base
  include UserModules::Tracker
  ...
end


mixin app/models/user_modules/tracker.rb
module UserModules
  module Tracker

    def get
      key = "user_" + self.id.to_s

      arr = Resque.redis.lrange(key, 0, -1)
      arr.map{|i| JSON.parse(i)}
    end


    def put(controller_name, action_name, details="")
      key     = "user_" + self.id.to_s
      created = Time.now.to_formatted_s(:db)}.to_json

      # silent exception handle, so you can do not run Redis localy
      begin
        Resque.redis.rpush key, {
          :controller_name => controller_name,
          :action_name     => action_name,
          :details         => details,
          :created_at      => created
      rescue
        nil
      end

    end

  end
end


controller app/controller/dashboard.rb
class Dashboard < ApplicationController
  after_filter :track, :only => :show

  # this action will be tracked
  def show
  end

  # this action will show tracking
  def logs_show
    render :json => current_user.get
  end

  ...

  private

  def track
    details = "any details...."
    current_user.put(controller_name, action_name, details)
  end
end

You must have Redis installed, I favor to make use of Resque as common method to setup and initialize Redis via Resque.redis, since it will help you browse your monitoring with resque-web

enter image description here

On of how to create Redis is within my gist