用户行为记录

This commit is contained in:
huang 2016-03-17 17:22:07 +08:00
parent 4999b47b44
commit 79767f4bae
6 changed files with 43 additions and 1 deletions

View File

@ -104,6 +104,8 @@ class AttachmentsController < ApplicationController
end
else
direct_download_history
# 记录用户行为
record_user_actions
end
end
else
@ -113,6 +115,10 @@ class AttachmentsController < ApplicationController
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end
def record_user_actions
UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id)
end
def download
# modify by nwb
# 下载添加权限设置

View File

@ -0,0 +1,4 @@
class UserActions < ActiveRecord::Base
attr_accessible :action_id, :action_type, :user_id
has_many :users
end

View File

@ -0,0 +1,11 @@
class CreateUserActions < ActiveRecord::Migration
def change
create_table :user_actions do |t|
t.integer :user_id
t.string :action_type
t.integer :action_id
t.timestamps
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160316055201) do
ActiveRecord::Schema.define(:version => 20160317090350) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1782,6 +1782,14 @@ ActiveRecord::Schema.define(:version => 20160316055201) do
t.integer "fields_bits", :default => 0
end
create_table "user_actions", :force => true do |t|
t.integer "user_id"
t.string "action_type"
t.integer "action_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "user_activities", :force => true do |t|
t.string "act_type"
t.integer "act_id"

View File

@ -0,0 +1,8 @@
FactoryGirl.define do
factory :user_action, :class => 'UserActions' do
user_id 1
action_type "MyString"
action_id 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe UserActions, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end