Generic gem to add notes to multiple tables

I’ve got an app where for several tables, A, B, C, they could use a list of associated “Notes”.

Is there any Rails gem that provides this sort of functionality?

A notes table would have the following cols:

id, parent_id, parent_table, note, created_by_id, updated_by_id, created_at, updated_at

I know GitHub - ctran/annotate_models: Annotate Rails classes with schema and routes info. I´m not sure if is exactly what do you want.

Not programmer notes, but notes on records. Kind of like what Devise does for auth.

Such a gem would:

  1. Create a Notes table
  2. Provide some UI hooks for displaying, it, etc.

Might be just too easy to create from scratch to make it worth a gem.

Sounds like you just need a polymorphic association. It’s hard to imagine any gem that would handle this since the needs would be very app-specific.

class Note < ActiveRecord::Base
  belongs_to :noteable, polymorphic: true
end
 
class Widget < ActiveRecord::Base
  has_many :notes, as: :noteable
end
1 Like