Class: ActiveRecord::Associations::HasAndBelongsToManyAssociation

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/habtm.rb

Instance Method Summary collapse

Instance Method Details

#find_or_create(object) ⇒ Object

Short alias for if exists then create

Parameters:

  • object (ActiveRecord::Base)

    An object to check if exists and create



4
5
6
# File 'lib/core_ext/habtm.rb', line 4

def find_or_create(object)
  self << object unless exists?(object)
end