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



15
16
17
18
# File 'app/models/asset/apply_id_to_name_on_create.rb', line 15

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

#generate_name_with_idObject



11
12
13
# File 'app/models/asset/apply_id_to_name_on_create.rb', line 11

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