Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7744419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:45:46+00:00 2026-06-01T09:45:46+00:00

I have an application where there are two types of user currently, Admin and

  • 0

I have an application where there are two types of user currently, Admin and Vendor, and i want to log their activities like

"TestAdmin" viewed transaction
"TestAdmin" added a new vendor
"TestAdmin" edited a Transaction
"TestVendor" added a new Transaction
"TestAdmin" approved Transaction 
"TestAdmin" rejected Transaction 
etc...

where “TestAdmin” is an admin and “TestVendor” is a vendor

But i m not sure what approach i should follow

I m thinking of this

Adding an Activity table in DB with following fields

user_id 
browser
session_id
ip_address
action
params

and call

before_filter :record_activity

to record all activities

but not sure how to create messages like above

Also i want to figure out if any error occurs and when and why, so for this i take browser fields to figure out whether code doesn’t work in IE etc. but this is only one error track field.

Please help and guide to some nice way to accomplish this.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:45:48+00:00Added an answer on June 1, 2026 at 9:45 am

    Ok this is what i did…

    First create table

    create_table "activity_logs", :force => true do |t|
        t.string "user_id"
        t.string "browser"
        t.string "ip_address"
        t.string "controller"
        t.string "action"
        t.string "params"
        t.string "note"
        t.datetime "created_at"
        t.datetime "updated_at"
    end
    

    created function in application controller

    def record_activity(note)
        @activity = Activity_Log.new
        @activity.user = current_user
        @activity.note = note
        @activity.browser = request.env['HTTP_USER_AGENT']
        @activity.ip_address = request.env['REMOTE_ADDR']
        @activity.controller = controller_name 
        @activity.action = action_name 
        @activity.params = params.inspect
        @activity.save
    end
    

    then call above function from any controller needed
    like this….

    class AccountsController < ApplicationController
          load_and_authorize_resource
    
          # POST /accounts
          # POST /accounts.json
         def create
           @account = Account.new(params[:account])
           respond_to do |format|
           if @account.save
            record_activity("Created new account") #This will call application controller  record_activity
            format.js { head :ok }
          else
           format.js { render json: @account.errors, :error => true, :success => false }
          end
        end
      end
    

    Hence problem solved……

    Thanks all for all their help….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application in which there is a form which I want to
In my application there is language detection. Languages have some identification code like en
I have an ascx component, that holds two-level menu, because there are several user
I'm designing an application that has two [three including administrators] user types: Buyers and
i am new to iPad developer, i have created two or three iPad application
I have two client applications connecting to an Windows Server AppFabric Cluster (there is
I have an application where there are multiple processes. They share the reading and
I have a asp.net application.there is a databinding section to a datagrid.But there have
I have an application deployed into multiple zones and there are some issues with
I have a simple Crud application where there is one filed called Category. During

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.