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 7014537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:32:02+00:00 2026-05-27T22:32:02+00:00

We are currently trying to build a Logging functionality for a Rails 3 application.

  • 0

We are currently trying to build a Logging functionality for a Rails 3 application. The Log Entry should be stored in the database and provide a link to the logged object. Objects of different classes should be loggable (e.g. tickets, interactions etc.).

How can we store the link to the views of these different objects? We were thinking about associations, but they are statically typed.

Is it possible to store associations to arbitrary objects?

  • 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-05-27T22:32:03+00:00Added an answer on May 27, 2026 at 10:32 pm

    Use polymorphic associations.

    class Log < ActiveRecord::Base
      belongs_to :logable, :polymorphic => true
    end
    
    class Ticket < ActiveRecord::Base
      has_many :logs, :as => :logable
      def to_label; name; end
    end
    
    class Interaction < ActiveRecord::Base
      has_many :logs, :as => :logable
      def to_label; title; end
    end
    

    Having a log, to link to it’s associated object’s show path do:

    <%= link_to @log.logable.to_label, @log.logable %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to build a simple component which should monitor, if the user
I'm currently trying to build an application that inherently needs good time synchronization across
I'm currently trying to build an authentication application in Android which stores users' username
I'm currently trying to build a personal website to create a presence on the
I am currently trying to build on TeamCity, which uses Microsoft.Office.Interop dll. This will
I'm currently trying to build a more or less complete set of unit tests
I am currently trying to build a very basic serial shell with my arduino.
I am trying to build an API that gives data on various cities. Currently,
I'm trying to build firefox but I'm having some problems. I currently have Visual
I'm trying to incorporate some JavaScript unit testing into my automated build process. Currently

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.