diff --git a/app/controllers/admin/user_actions_controller.rb b/app/controllers/admin/user_actions_controller.rb new file mode 100644 index 00000000..dff3a432 --- /dev/null +++ b/app/controllers/admin/user_actions_controller.rb @@ -0,0 +1,6 @@ +class Admin::UserActionsController < OrbitBackendController + + def index + @user_actions = UserAction.all + end +end \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c1de055e..8f0c6870 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,6 +29,7 @@ class ApplicationController < ActionController::Base def set_current_user User.current = current_or_guest_user + UserActionRecoder.perform(current_or_guest_user,params) end def front_end_available(module_app_title='') diff --git a/app/jobs/user_action_recoder.rb b/app/jobs/user_action_recoder.rb new file mode 100644 index 00000000..d5cd9281 --- /dev/null +++ b/app/jobs/user_action_recoder.rb @@ -0,0 +1,8 @@ +class UserActionRecoder + @queue = :low + def self.perform(user,params) + UserAction.create!(:user=>user,:params=>params,:page=>"#{params['controller']}##{params['action']}") + true + end + +end \ No newline at end of file diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 4b3a9e6e..4a01a71c 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -31,6 +31,8 @@ class User # has_many :papers, :autosave => true, :dependent => :destroy has_and_belongs_to_many :sub_role_tags + has_many :user_actions, :dependent => :destroy + # has_and_belongs_to_many :statuses has_and_belongs_to_many :roles has_and_belongs_to_many :sub_roles diff --git a/app/models/user/user_action.rb b/app/models/user/user_action.rb new file mode 100644 index 00000000..b49af689 --- /dev/null +++ b/app/models/user/user_action.rb @@ -0,0 +1,10 @@ +class UserAction + include Mongoid::Document + include Mongoid::Timestamps + + belongs_to :user + field :params,:type => Hash + + field :page + +end \ No newline at end of file diff --git a/app/views/admin/user_actions/index.html.erb b/app/views/admin/user_actions/index.html.erb new file mode 100644 index 00000000..74e4ea5f --- /dev/null +++ b/app/views/admin/user_actions/index.html.erb @@ -0,0 +1,16 @@ +
時間 | +使用帳號 | +頁面 | +
---|---|---|
<%= user_action.created_at %> | +<%= user_action.user.name %> | +<%= user_action.page %> | +