Class: Effective::LogsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Effective::LogsController
- Defined in:
- app/controllers/effective/logs_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
This is a post from our Javascript.
-
#index ⇒ Object
This is the User index event.
-
#show ⇒ Object
This is the User show event.
Instance Method Details
#create ⇒ Object
This is a post from our Javascript
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/effective/logs_controller.rb', line 7 def create EffectiveLogging.(self, :create, Effective::Log.new()) @log = Effective::Log.new().tap do |log| log. = log_params[:message] log.status = (EffectiveLogging.statuses.include?(log_params[:status]) ? log_params[:status] : 'info') log.user = (current_user rescue nil) #log.parent = options.delete(:parent) #log.associated = options.delete(:associated) count = -1 Array((JSON.parse(log_params[:details]) rescue [])).flatten(1).each do |obj| if obj.kind_of?(Hash) obj.each { |k, v| log.details[k] = v if v.present? } else log.details["param_#{(count += 1)}"] = obj if obj.present? end end log.details[:referrer] = request.referrer log.save end render :text => "ok", :status => :ok end |
#index ⇒ Object
This is the User index event
36 37 38 39 40 41 |
# File 'app/controllers/effective/logs_controller.rb', line 36 def index @datatable = Effective::Datatables::Logs.new(:user_id => current_user.id) if defined?(EffectiveDatatables) @page_title = 'My Activity' EffectiveLogging.(self, :index, Effective::Log.new(:user_id => current_user.id)) end |
#show ⇒ Object
This is the User show event
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/effective/logs_controller.rb', line 44 def show @log = Effective::Log.where(:user_id => current_user.id).includes(:logs).find(params[:id]) @log.next_log = Effective::Log.unscoped.where(:user_id => current_user.id).order(:id).where(:parent_id => @log.parent_id).where('id > ?', @log.id).first @log.prev_log = Effective::Log.unscoped.where(:user_id => current_user.id).order(:id).where(:parent_id => @log.parent_id).where('id < ?', @log.id).last @page_title = "Log ##{@log.to_param}" if @log.logs.present? @log.datatable = Effective::Datatables::Logs.new(:user_id => current_user.id, :log_id => @log.id) if defined?(EffectiveDatatables) end EffectiveLogging.(self, :show, @log) end |