23 lines
523 B
Ruby
23 lines
523 B
Ruby
class RelationshipsController < ApplicationController
|
|
def add_child
|
|
parent = Person.find(params[:parent])
|
|
child = Child.find(params[:child])
|
|
|
|
ap parent
|
|
ap child
|
|
|
|
parent.parenthoods.create(child_id: child.to_i)
|
|
|
|
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
|