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