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
Not programmer notes, but notes on records. Kind of like what Devise does for auth.
Such a gem would:
- Create a Notes table
- Provide some UI hooks for displaying, it, etc.
Might be just too easy to create from scratch to make it worth a gem.
andyw8
(Andy Waite)
4
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