Method: AbstractResource#attach

Defined in:
app/models/abstract_resource.rb

#attach(parent) ⇒ Object

# add the child to an association of children !! remember to implement before_save action on *able tables to meet further foreign_key conditions like account_id, etc



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'app/models/abstract_resource.rb', line 119

def attach parent

  # the ordinary *able table
  parent.send( self.class.to_s.underscore.pluralize) << self

  # case child.class.to_s
  # when "Event","WageEvent"
  #   Eventable.create( event: child, eventable: self) unless child.eventables.include?( self)
  # when "Printer"
  #   Printable.create( printer: child, printable: self) unless child.printables.include?( self)
  # else
  #   children = eval child.class.to_s.underscore.pluralize
  #   children << child
  # end
rescue
  false
end