2015-10-03 08:04:16 -05:00
|
|
|
class RelationshipsController < ApplicationController
|
|
|
|
def add_child
|
|
|
|
parent = Person.find(params[:parent])
|
|
|
|
child = Child.find(params[:child])
|
|
|
|
|
2015-10-03 15:15:19 -05:00
|
|
|
ap parent
|
|
|
|
ap child
|
|
|
|
|
|
|
|
parent.parenthoods.create(child_id: child.to_i)
|
2015-10-03 08:04:16 -05:00
|
|
|
|
|
|
|
redirect_to :back, notice: 'Child added to parent!'
|
|
|
|
end
|
|
|
|
|
|
|
|
def del_child
|
|
|
|
parent = Person.find(params[:parent])
|
|
|
|
child = Child.find(params[:child])
|
|
|
|
|
|
|
|
parent.parenthoods.find_by_child_id(child.id).destroy
|
|
|
|
|
|
|
|
redirect_to :back, notice: 'Child removed from parent!'
|
|
|
|
end
|
|
|
|
end
|