Module: Models::Notable

Extended by:
ActiveSupport::Concern
Included in:
Delivery, Invoice, Opportunity, Order, Party, Quote, RoomConfiguration
Defined in:
app/concerns/models/notable.rb

Overview

ActiveSupport::Concern mixin: notable.

Instance Method Summary collapse

Instance Method Details

#quick_note(content) ⇒ Activity?

Records a note activity for the record's primary party.

Parameters:

  • content (String, nil)

    note text; blank content is ignored

Returns:

  • (Activity, nil)

    the created activity, or nil when content is blank or no primary party exists



13
14
15
16
17
18
19
20
21
22
# File 'app/concerns/models/notable.rb', line 13

def quick_note(content)
  return if content.blank?

  party_id = begin
    primary_party.id
  rescue StandardError
    nil
  end
  activities.create(party_id: party_id, new_note: content) unless party_id.nil?
end