Module: Asset::ApplyIdToNameOnCreate

Extended by:
ActiveSupport::Concern
Defined in:
app/models/asset/apply_id_to_name_on_create.rb

Overview

Include in classes to add the id onto any name added via #generate_name on create.

Instance Method Summary collapse

Instance Method Details

#generate_name(new_name) ⇒ Object


17
18
19
20
# File 'app/models/asset/apply_id_to_name_on_create.rb', line 17

def generate_name(new_name)
  self.name = new_name
  @name_needs_to_be_generated = true
end

#generate_name_with_idObject


13
14
15
# File 'app/models/asset/apply_id_to_name_on_create.rb', line 13

def generate_name_with_id
  update!(name: "#{name} #{id}")
end